venaas Sat Jan 13 02:00:31 2001 EDT
Modified files:
/php4/ext/ldap ldap.c
Log:
Fixed memory leaks that could happen in some error situations. Also removed
some unnecessary code in ldap_set_option()
Index: php4/ext/ldap/ldap.c
diff -u php4/ext/ldap/ldap.c:1.79 php4/ext/ldap/ldap.c:1.80
--- php4/ext/ldap/ldap.c:1.79 Fri Jan 12 14:08:26 2001
+++ php4/ext/ldap/ldap.c Sat Jan 13 02:00:27 2001
@@ -23,7 +23,7 @@
*/
-/* $Id: ldap.c,v 1.79 2001/01/12 22:08:26 venaas Exp $ */
+/* $Id: ldap.c,v 1.80 2001/01/13 10:00:27 venaas Exp $ */
#define IS_EXT_MODULE
#include "php.h"
@@ -235,7 +235,7 @@
php_info_print_table_start();
php_info_print_table_row(2, "LDAP Support", "enabled" );
- php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.79 2001/01/12
22:08:26 venaas Exp $" );
+ php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.80 2001/01/13
+10:00:27 venaas Exp $" );
php_info_print_table_row(2, "Total Links", maxl );
#ifdef LDAP_API_VERSION
snprintf(ldapapiversion, 31, "%d", LDAP_API_VERSION);
@@ -660,6 +660,7 @@
for(i=0; i<num_attribs; i++) {
if(zend_hash_index_find((*attrs)->value.ht, i, (void
**) &attr) == FAILURE) {
php_error(E_WARNING, "LDAP: Array
initialization wrong");
+ efree(ldap_attrs);
RETURN_FALSE;
}
@@ -778,7 +779,12 @@
}
ldap = _get_ldap_link(link);
- if (ldap == NULL) RETURN_FALSE;
+ if (ldap == NULL) {
+ if (ldap_attrs != NULL) {
+ efree(ldap_attrs);
+ }
+ RETURN_FALSE;
+ }
php_set_opts(ldap, ldap_sizelimit, ldap_timelimit, ldap_deref);
@@ -1387,6 +1393,12 @@
ldap_mods[i]->mod_type = estrdup(attribute);
} else {
php_error(E_ERROR, "LDAP: Unknown Attribute in the data");
+ /* Free allocated memory */
+ while (i >= 0) {
+ efree(ldap_mods[i--]);
+ }
+ efree(num_berval);
+ efree(ldap_mods);
RETURN_FALSE;
}
@@ -1770,9 +1782,6 @@
RETURN_FALSE;
}
ctrls = emalloc((1 + ncontrols) * sizeof(*ctrls));
- if (ctrls == NULL) {
- RETURN_FALSE;
- }
*ctrls = NULL;
ctrlp = ctrls;
zend_hash_internal_pointer_reset(Z_ARRVAL_PP(newval));
@@ -1781,7 +1790,6 @@
php_error(E_WARNING, "The array value must
contain only arrays, where each array is a control");
error = 1;
break;
- RETURN_FALSE;
}
if (zend_hash_find(Z_ARRVAL_PP(ctrlval), "oid",
sizeof("oid"), (void **) &val) == FAILURE) {
php_error(E_WARNING, "Control must have an oid
key");
@@ -1789,10 +1797,6 @@
break;
}
ctrl = *ctrlp = emalloc(sizeof(**ctrlp));
- if (ctrl == NULL) {
- error = 1;
- break;
- }
convert_to_string_ex(val);
ctrl->ldctl_oid = Z_STRVAL_PP(val);
if (zend_hash_find(Z_ARRVAL_PP(ctrlval), "value",
sizeof("value"), (void **) &val) == SUCCESS) {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]