1
0
mirror of https://github.com/simh/simh.git synced 2026-01-13 15:27:14 +00:00

SCP: sprint_val comma bug

- Fix comma separator code segmentation fault: "ndigit - 3" can become a
  very large unsigned number for ndigit < 3.
This commit is contained in:
B. Scott Michel 2024-03-21 13:55:52 -10:00 committed by Mark Pizzolato
parent eab060315e
commit f7dfefee72

2
scp.c
View File

@ -12459,7 +12459,7 @@ switch (format) {
break;
ndigits = MAX_WIDTH - digit;
commas = (ndigits - 1)/3;
for (digit=0; digit<ndigits-3; digit++)
for (digit=0; (digit + 3) < ndigits; digit++)
dbuf[MAX_WIDTH + (digit - ndigits) - (ndigits - digit - 1)/3] = dbuf[MAX_WIDTH + (digit - ndigits)];
for (digit=1; digit<=commas; digit++)
dbuf[MAX_WIDTH - (digit * 4)] = ',';