From: Kurt Zeilenga Date: Tue, 8 Oct 2002 19:45:01 +0000 (+0000) Subject: Plug memory leak (ITS#2126) X-Git-Tag: NO_SLAP_OP_BLOCKS~914 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=873a6802ab10898929cb9c0cc944d99beac56c3f;p=openldap Plug memory leak (ITS#2126) --- diff --git a/libraries/liblunicode/ucstr.c b/libraries/liblunicode/ucstr.c index bc46a95169..69fce783f8 100644 --- a/libraries/liblunicode/ucstr.c +++ b/libraries/liblunicode/ucstr.c @@ -98,7 +98,7 @@ struct berval * UTF8bvnormalize( unsigned flags ) { int i, j, len, clen, outpos, ucsoutlen, outsize, last; - char *out, *s; + char *out, *outtmp, *s; unsigned long *ucs, *p, *ucsout; unsigned casefold = flags & LDAP_UTF8_CASEFOLD; @@ -227,15 +227,21 @@ struct berval * UTF8bvnormalize( 6 bytes and terminator */ if ( outsize - outpos < 7 ) { outsize = ucsoutlen - j + outpos + 6; - out = (char *) realloc( out, outsize ); - if ( out == NULL ) { + outtmp = (char *) realloc( out, outsize ); + if ( outtmp == NULL ) { + free( out ); free( ucs ); + free( ucsout ); return NULL; } + out = outtmp; } outpos += ldap_x_ucs4_to_utf8( ucsout[j], &out[outpos] ); } } + + free( ucsout ); + ucsout = NULL; if ( i == len ) { break;