mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 21:40:20 +00:00
debug_dump: overflow fix
The printout includes pointer, which was at the time of writting supposed to be 32, in which case the line length was: 2 /* 0x */ + 8 /* ptr */ + 1 /* : */ + 3 * 16 /* " XX" */ + 16 /* char repr */ + 5 /* additiona separators */ + 1 /* NL */ = 81 (separators - 2 betweeh group of hexa and char repre, 3 between hexa and char represenatation) With 64 bit pinters, it can be at most 89 bytes. To keep the old length, removed one space between every pair of hexadecimal byte representation - it is still good legible, compatibile with xxd, still keeping the 80 long line..
This commit is contained in:
@@ -193,10 +193,12 @@ void debug_dump(const void *lp, int len)
|
||||
/* display each character as hex value */
|
||||
for (i = start, j = 0; j < 16; p++, i++, j++) {
|
||||
if (i < len) {
|
||||
snprintf(tmpBuf, sizeof tmpBuf, "%02X ", ((int)(*p) & 0xFF));
|
||||
snprintf(tmpBuf, sizeof tmpBuf, "%02X", ((int)(*p) & 0xFF));
|
||||
strcat(Buff, tmpBuf);
|
||||
} else
|
||||
strcat(Buff, " ");
|
||||
if (j % 2 == 1) /* space between groups of 2 */
|
||||
strcat(Buff, " ");
|
||||
if (j == 7) /* space between groups of 8 */
|
||||
strcat(Buff, " ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user