In the unlikely case of a VM with zero disks, a jsonPerDiskFmtFooterLast
should not be emitted.
}
#endif
}
- /* Terminate the last element of the disk partition JSON array. */
- DynBuf_Append(&dynBuffer, jsonPerDiskFmtFooterLast,
- sizeof jsonPerDiskFmtFooterLast - 1);
+ if (pdi->numEntries > 0) {
+ /* Terminate the last element of the disk partition JSON array. */
+ DynBuf_Append(&dynBuffer, jsonPerDiskFmtFooterLast,
+ sizeof jsonPerDiskFmtFooterLast - 1);
+ }
DynBuf_Append(&dynBuffer, jsonSuffix, sizeof jsonSuffix - 1);