https://bugs.openldap.org/show_bug.cgi?id=9198
--- Comment #2 from 1259039012@qq.com --- Comment on attachment 696 --> https://bugs.openldap.org/attachment.cgi?id=696 This is my fixed code.
The variable 'newbv' of utf8bvnormalize function is not released when the function returns abnormally.
example: if ( !newbv ) { newbv = ber_memalloc_x( sizeof(struct berval), ctx ); if ( !newbv ) return NULL; }
... /* finish off everything up to character before first non-ascii */ if ( LDAP_UTF8_ISASCII( s ) ) { if ( casefold ) { outsize = len + 7; out = (char *) ber_memalloc_x( outsize, ctx ); if ( out == NULL ) { return NULL; //newbv has leak! } ... } ... }
This problem also exists in other return statements in this function.