mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 00:29:35 -05:00
don't leak if realloc fails (ITS#4477)
This commit is contained in:
parent
c6ab0790d1
commit
b03d8abcde
1 changed files with 13 additions and 0 deletions
|
|
@ -261,6 +261,10 @@ slap_sl_malloc(
|
|||
unsigned long diff;
|
||||
int i, j;
|
||||
|
||||
#ifdef SLAP_NO_SL_MALLOC
|
||||
return ber_malloc_x( size, NULL );
|
||||
#endif
|
||||
|
||||
/* ber_set_option calls us like this */
|
||||
if (!ctx) return ber_memalloc_x(size, NULL);
|
||||
|
||||
|
|
@ -365,6 +369,10 @@ slap_sl_realloc(void *ptr, ber_len_t size, void *ctx)
|
|||
if (ptr == NULL)
|
||||
return slap_sl_malloc(size, ctx);
|
||||
|
||||
#ifdef SLAP_NO_SL_MALLOC
|
||||
return ber_memrealloc_x( ptr, size, NULL );
|
||||
#endif
|
||||
|
||||
/* Not our memory? */
|
||||
if (!sh || ptr < sh->sh_base || ptr >= sh->sh_end) {
|
||||
/* duplicate of realloc behavior, oh well */
|
||||
|
|
@ -434,6 +442,11 @@ slap_sl_free(void *ptr, void *ctx)
|
|||
if (!ptr)
|
||||
return;
|
||||
|
||||
#ifdef SLAP_NO_SL_MALLOC
|
||||
ber_memfree_x( ptr, NULL );
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (!sh || ptr < sh->sh_base || ptr >= sh->sh_end) {
|
||||
ber_memfree_x(ptr, NULL);
|
||||
} else if (sh->sh_stack && (char *)ptr + p[-1] == sh->sh_last) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue