-
Notifications
You must be signed in to change notification settings - Fork 771
Memory leak on realloc(3) failure. #88
Copy link
Copy link
Closed
Description
s2n_realloc() does b->data = realloc(b->data, size) and if b->data is then NULL it returns an error. By then, the reference to the still allocated, still valid, original memory at the original b->data has been lost and the memory leaked. b->data is now NULL yet b->size isn't zero. (This is a very common pattern of error when using realloc(3).) The return value of realloc() needs storing in a temporary and the library needs to decide if b is still intended to be valid on realloc() failure. (I would expect so.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels