sanity check on return value

This commit is contained in:
JacobBarthelmeh
2022-09-26 10:40:41 -07:00
parent cc4e8df56d
commit 1e348eb7bd

View File

@ -15631,15 +15631,20 @@ int sp_todecimal(sp_int* a, char* str)
i = 0; i = 0;
while (!sp_iszero(t)) { while (!sp_iszero(t)) {
sp_div_d(t, 10, t, &d); err = sp_div_d(t, 10, t, &d);
if (err != MP_OKAY) {
break;
}
str[i++] = (char)('0' + d); str[i++] = (char)('0' + d);
} }
str[i] = '\0'; str[i] = '\0';
for (j = 0; j <= (i - 1) / 2; j++) { if (err == MP_OKAY) {
int c = (unsigned char)str[j]; for (j = 0; j <= (i - 1) / 2; j++) {
str[j] = str[i - 1 - j]; int c = (unsigned char)str[j];
str[i - 1 - j] = (char)c; str[j] = str[i - 1 - j];
str[i - 1 - j] = (char)c;
}
} }
} }