Skip to content

Commit

Permalink
Fix invalid free() after failed realloc() (GHSA-gcx3-7m76-287p)
Browse files Browse the repository at this point in the history
  • Loading branch information
PetteriAimonen committed Feb 1, 2020
1 parent c8e8fe1 commit 7b39682
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pb_decode.c
Expand Up @@ -627,11 +627,11 @@ static bool checkreturn decode_pointer_field(pb_istream_t *stream, pb_wire_type_
size_t *size = (size_t*)iter->pSize;
void *pItem;

(*size)++;
if (!allocate_field(stream, iter->pData, iter->pos->data_size, *size))
if (!allocate_field(stream, iter->pData, iter->pos->data_size, (size_t)(*size + 1)))
return false;

pItem = *(uint8_t**)iter->pData + iter->pos->data_size * (*size - 1);
pItem = *(uint8_t**)iter->pData + iter->pos->data_size * (*size);
(*size)++;
initialize_pointer_field(pItem, iter);
return func(stream, iter->pos, pItem);
}
Expand Down

0 comments on commit 7b39682

Please sign in to comment.