Recent commit
90bfbea7c0 ("BUG/MINOR: ssl: fix memory leaks on realloc
failure in ssl_sock.c") accidentally turned a memory leak in case of
allocation failure into a double-free: the original pointer must no
longer be released. In addition, the allocated_size has to be reset
in case of failure. This needs to be backported to 3.3 like previous
commit.
/* insufficient storage, reallocate */
len = (len + 7) & -8; /* round to the nearest 8 bytes */
ptr = my_realloc2(ptr, len);
- if (!ptr)
- free(s->ssl_ctx.reused_sess[tid].ptr);
s->ssl_ctx.reused_sess[tid].ptr = ptr;
- s->ssl_ctx.reused_sess[tid].allocated_size = len;
+ s->ssl_ctx.reused_sess[tid].allocated_size = ptr ? len : 0;
}
if (ptr) {