From 59873eb9cd82f7aa6e41e878ef395bfa4bf738fc Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Sat, 23 Feb 2013 21:11:13 +0000 Subject: fix a problem in memory handling in myldap_get_values_len() if malloc() would fail (r1909 from 0.9) git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd-0.8@1932 ef36b2f9-881f-0410-afb5-c4e39611909c --- nslcd/myldap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nslcd/myldap.c b/nslcd/myldap.c index 3cc9da5..1922a93 100644 --- a/nslcd/myldap.c +++ b/nslcd/myldap.c @@ -1572,8 +1572,7 @@ static const char **bervalues_to_values(struct berval **bvalues) values=(char **)malloc(sz); if (values==NULL) { - log_log(LOG_CRIT,"myldap_get_values_len(): malloc() failed to allocate memory"); - ldap_value_free_len(bvalues); + log_log(LOG_CRIT,"bervalues_to_values(): malloc() failed to allocate memory"); return NULL; } buf=(char *)values; @@ -1649,6 +1648,9 @@ const char **myldap_get_values_len(MYLDAP_ENTRY *entry,const char *attr) values=bervalues_to_values(bvalues); ldap_value_free_len(bvalues); } + /* check if we got allocated memory */ + if (values==NULL) + return NULL; /* store values entry so we can free it later on */ for (i=0;irangedattributevalues[i]==NULL) -- cgit v1.2.3