scan-build didn't like the unlimited version since we might need to
overflow size_t to hexify a string that took up half our address
space. (!)
const unsigned char *val = val_;
char *result, *cp;
size_t i;
+ int ellipses = 0;
if (!val)
return strdup("null");
- if (!(result = malloc(len*2+1)))
+ if (len > 1024) {
+ ellipses = 3;
+ len = 1024;
+ }
+ if (!(result = malloc(len*2+4)))
return strdup("<allocation failure>");
cp = result;
for (i=0;i<len;++i) {
*cp++ = "0123456789ABCDEF"[val[i] >> 4];
*cp++ = "0123456789ABCDEF"[val[i] & 0x0f];
}
+ while (ellipses--)
+ *cp++ = '.';
*cp = 0;
return result;
}