From f967ec3b4e719cc15502c456d53ac8f8e6570c79 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 29 Jan 2010 23:11:24 +0000 Subject: [PATCH] Set res parameter to NULL upon ldap_search_ext_s entry. Likewise for friends. Note in manual that res parameter should be freed regardless of return value of ldap_search_ext_s (or friends). --- doc/man/man3/ldap_search.3 | 8 ++++++++ libraries/libldap/search.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/doc/man/man3/ldap_search.3 b/doc/man/man3/ldap_search.3 index 770ed3b5bd..67e6c5f05e 100644 --- a/doc/man/man3/ldap_search.3 +++ b/doc/man/man3/ldap_search.3 @@ -114,6 +114,14 @@ emulate read) or LDAP_SCOPE_ONELEVEL (to emulate list). These routines may dynamically allocate memory. The caller is responsible for freeing such memory using supplied deallocation routines. Return values are contained in . +.LP +Note that \fIres\fR parameter of +.B ldap_search_ext_s() +and +.B ldap_search_s() +should be freed with +.B ldap_msgfree() +regardless of return value of these functions. .SH DEPRECATED INTERFACES The .B ldap_search() diff --git a/libraries/libldap/search.c b/libraries/libldap/search.c index 5c4e234e72..6da091aa17 100644 --- a/libraries/libldap/search.c +++ b/libraries/libldap/search.c @@ -169,6 +169,8 @@ ldap_pvt_search_s( int rc; int msgid; + *res = NULL; + rc = ldap_pvt_search( ld, base, scope, filter, attrs, attrsonly, sctrls, cctrls, timeout, sizelimit, deref, &msgid ); @@ -393,6 +395,8 @@ ldap_search_st( { int msgid; + *res = NULL; + if ( (msgid = ldap_search( ld, base, scope, filter, attrs, attrsonly )) == -1 ) return( ld->ld_errno ); @@ -421,6 +425,8 @@ ldap_search_s( { int msgid; + *res = NULL; + if ( (msgid = ldap_search( ld, base, scope, filter, attrs, attrsonly )) == -1 ) return( ld->ld_errno ); -- 2.39.5