Fix potential bugs found with static analysis

This commit is contained in:
vit9696 2019-03-26 14:22:51 +03:00
parent 2cbd78fb9e
commit 5edd5c10ee
4 changed files with 16 additions and 10 deletions

View file

@ -2399,7 +2399,10 @@ int i, c, v;
v = (bl->qty - 1) * len;
if ((bl->qty > 512 || len > 127) &&
v / len != bl->qty - 1) return NULL; /* Overflow */
if (v > INT_MAX - c) return NULL; /* Overflow */
if (v > INT_MAX - c) {
bstr__free (b);
return NULL; /* Overflow */
}
c += v;
p = b->data = (unsigned char *) bstr__alloc (c);
if (p == NULL) {
@ -2542,6 +2545,7 @@ int bssplitstrcb (struct bStream * s, const_bstring splitStr,
}
buff->slen = 0;
}
bdestroy (buff);
return BSTR_OK;
} else {
for (;;) {