Skip to content

Commit

Permalink
Ticket #47774 mem leak in do_search - rawbase not freed upon certain …
Browse files Browse the repository at this point in the history
…errors

https://fedorahosted.org/389/ticket/47774
Reviewed by: nhosoi (Thanks!)
Branch: 389-ds-base-1.2.11
Fix Description: Free the local rawbase variable if it was not set in the
pblock.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 1d5c6d6)
(cherry picked from commit b065515)
(cherry picked from commit 97f58ff4787ecb87780fde7245e354ec75e73125)
(cherry picked from commit 33bf4d42727804f5c10ce30834a2340c99cad459)
  • Loading branch information
richm committed Apr 9, 2014
1 parent 7655ff7 commit 9426e07
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ldap/servers/slapd/search.c
Expand Up @@ -69,6 +69,7 @@ do_search( Slapi_PBlock *pb )
int i, err, attrsonly;
ber_int_t scope, deref, sizelimit, timelimit;
char *rawbase = NULL;
int rawbase_set_in_pb = 0; /* was rawbase set in pb? */
char *base = NULL, *fstr = NULL;
struct slapi_filter *filter = NULL;
char **attrs = NULL;
Expand Down Expand Up @@ -339,6 +340,7 @@ do_search( Slapi_PBlock *pb )
}

slapi_pblock_set( pb, SLAPI_ORIGINAL_TARGET_DN, rawbase );
rawbase_set_in_pb = 1; /* rawbase is now owned by pb */
slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, &scope );
slapi_pblock_set( pb, SLAPI_SEARCH_DEREF, &deref );
slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, filter );
Expand Down Expand Up @@ -375,7 +377,9 @@ free_and_return:;
operation->o_flags &= ~OP_FLAG_PS;
}
/* we strdup'd this above - need to free */
slapi_pblock_get(pb, SLAPI_ORIGINAL_TARGET_DN, &rawbase);
if (rawbase_set_in_pb) {
slapi_pblock_get(pb, SLAPI_ORIGINAL_TARGET_DN, &rawbase);
}
slapi_ch_free_string(&rawbase);
}
}
Expand Down

0 comments on commit 9426e07

Please sign in to comment.