Skip to content
Snippets Groups Projects
Commit 2330f146 authored by Hallvard Furuseth's avatar Hallvard Furuseth
Browse files

Plug memory leaks (free output from ldif_parse_line)

parent 03ea0681
No related branches found
No related tags found
No related merge requests found
...@@ -192,9 +192,15 @@ Re_parse( ...@@ -192,9 +192,15 @@ Re_parse(
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
"Error: Re_parse: bad type <%s>\n", "Error: Re_parse: bad type <%s>\n",
type, 0, 0 ); type, 0, 0 );
free( type );
if ( value != NULL )
free( value );
return -1; return -1;
} }
} }
free( type );
if ( value != NULL )
free( value );
} }
if ( state != GOT_ALL ) { if ( state != GOT_ALL ) {
...@@ -205,12 +211,14 @@ Re_parse( ...@@ -205,12 +211,14 @@ Re_parse(
} }
for (;;) { for (;;) {
char *const dash = "-";
if (( buf = ldif_getline( &rp )) == NULL ) { if (( buf = ldif_getline( &rp )) == NULL ) {
break; break;
} }
buflen = strlen( buf ); buflen = strlen( buf );
if (( buflen == 1 ) && ( buf[ 0 ] == '-' )) { if (( buflen == 1 ) && ( buf[ 0 ] == '-' )) {
type = "-"; type = dash;
value = NULL; value = NULL;
} else { } else {
if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) { if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) {
...@@ -235,6 +243,11 @@ Re_parse( ...@@ -235,6 +243,11 @@ Re_parse(
re->re_mods[ nml + 1 ].mi_type = NULL; re->re_mods[ nml + 1 ].mi_type = NULL;
re->re_mods[ nml + 1 ].mi_val = NULL; re->re_mods[ nml + 1 ].mi_val = NULL;
nml++; nml++;
if ( type != dash )
free( type );
if ( value != NULL )
free( value );
} }
return 0; return 0;
} }
...@@ -314,8 +327,11 @@ get_repl_hosts( ...@@ -314,8 +327,11 @@ get_repl_hosts(
break; break;
} }
} }
free( type );
if ( !repl_ok ) { if ( !repl_ok ) {
warn_unknown_replica( value, port ); warn_unknown_replica( value, port );
if ( value != NULL )
free( value );
continue; continue;
} }
...@@ -328,6 +344,9 @@ get_repl_hosts( ...@@ -328,6 +344,9 @@ get_repl_hosts(
rh[ nreplicas ].rh_hostname = strdup( value ); rh[ nreplicas ].rh_hostname = strdup( value );
rh[ nreplicas ].rh_port = port; rh[ nreplicas ].rh_port = port;
nreplicas++; nreplicas++;
if ( value != NULL )
free( value );
} }
if ( nreplicas == 0 ) { if ( nreplicas == 0 ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment