-
Notifications
You must be signed in to change notification settings - Fork 771
Memory leak in s2n_realloc #181
Copy link
Copy link
Closed
Description
I'm just eyeballing this so perhaps I'm missing something, but the following code in s2n_realloc seems to leak any old buffer in b->data:
...
// Allocate new memory block.
void *data;
if (posix_memalign(&data, page_size, allocate)) {
S2N_ERROR(S2N_ERR_ALLOC);
}
// Copy old data to new data. Check the size first so that we don't copy
// from NULL (may want to test b->data instead?)
if (b->size) {
memcpy_check(data, b->data, b->size);
}
// Assign new data to `b`. NOTE: OLD b->data NOT CLEANED UP FIRST!
b->data = data;
b->size = size;
b->allocated = allocate;
...
This code was introduced in 3a418cc as part of aligning the data buffer to a page size.
If there is a problem here that needs to be fixed, please also note the other reported issue regarding a lack of a call to munlock when freeing a block.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels