jani Fri Jul 13 01:24:16 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src NEWS
/php-src/ext/ldap ldap.c php_ldap.h
Log:
MFH:- Fixed bug #41127 (Memory leak in ldap_{first|next}_attribute functions)
# This removes an useless parameter from 2 functions. Perhaps the next
# release should be 5.3.0, there are lot of other new things done already.
# Sneak in namespaces too.. ;)
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.833&r2=1.2027.2.547.2.834&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.833 php-src/NEWS:1.2027.2.547.2.834
--- php-src/NEWS:1.2027.2.547.2.833 Thu Jul 12 22:08:58 2007
+++ php-src/NEWS Fri Jul 13 01:24:15 2007
@@ -142,6 +142,8 @@
integer as sections). (Tony)
- Fixed bug #41350 (my_thread_global_end() error during request shutdown
on Windows). (Scott, Andrey)
+- Fixed bug #41127 (Memory leak in ldap_{first|next}_attribute functions).
+ (Jani)
- Fixed bug #40419 (Trailing slash in CGI request does not work). (Dmitry)
- Fixed bug #39330 (apache2handler does not call shutdown actions before
apache child die). (isk at ecommerce dot com, Gopal, Tony)
http://cvs.php.net/viewvc.cgi/php-src/ext/ldap/ldap.c?r1=1.161.2.3.2.6&r2=1.161.2.3.2.7&diff_format=u
Index: php-src/ext/ldap/ldap.c
diff -u php-src/ext/ldap/ldap.c:1.161.2.3.2.6
php-src/ext/ldap/ldap.c:1.161.2.3.2.7
--- php-src/ext/ldap/ldap.c:1.161.2.3.2.6 Thu Jul 12 22:08:58 2007
+++ php-src/ext/ldap/ldap.c Fri Jul 13 01:24:16 2007
@@ -23,7 +23,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ldap.c,v 1.161.2.3.2.6 2007/07/12 22:08:58 jani Exp $ */
+/* $Id: ldap.c,v 1.161.2.3.2.7 2007/07/13 01:24:16 jani Exp $ */
#define IS_EXT_MODULE
#ifdef HAVE_CONFIG_H
@@ -75,6 +75,7 @@
typedef struct {
LDAPMessage *data;
+ BerElement *ber;
int id;
} ldap_resultentry;
@@ -91,7 +92,7 @@
ZEND_ARG_PASS_INFO(1)
ZEND_END_ARG_INFO();
-static int le_link, le_result, le_result_entry, le_ber_entry;
+static int le_link, le_result, le_result_entry;
/*
This is just a small subset of the functionality provided by the LDAP
library. All the
@@ -217,6 +218,10 @@
static void _free_ldap_result_entry(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
ldap_resultentry *entry = (ldap_resultentry *)rsrc->ptr;
+
+ if (entry->ber != NULL) {
+ ber_free(entry->ber, 0);
+ }
zend_list_delete(entry->id);
efree(entry);
}
@@ -286,10 +291,9 @@
REGISTER_LONG_CONSTANT("GSLC_SSL_TWOWAY_AUTH", GSLC_SSL_TWOWAY_AUTH,
CONST_PERSISTENT | CONST_CS);
#endif
- le_result = zend_register_list_destructors_ex(_free_ldap_result, NULL,
"ldap result", module_number);
le_link = zend_register_list_destructors_ex(_close_ldap_link, NULL,
"ldap link", module_number);
+ le_result = zend_register_list_destructors_ex(_free_ldap_result, NULL,
"ldap result", module_number);
le_result_entry =
zend_register_list_destructors_ex(_free_ldap_result_entry, NULL, "ldap result
entry", module_number);
- le_ber_entry = zend_register_list_destructors_ex(NULL, NULL, "ldap ber
entry", module_number);
Z_TYPE(ldap_module_entry) = type;
@@ -318,7 +322,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.161.2.3.2.6
2007/07/12 22:08:58 jani Exp $");
+ php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.161.2.3.2.7
2007/07/13 01:24:16 jani Exp $");
if (LDAPG(max_links) == -1) {
snprintf(tmp, 31, "%ld/unlimited", LDAPG(num_links));
@@ -993,6 +997,7 @@
resultentry->id = Z_LVAL_PP(result);
zend_list_addref(resultentry->id);
resultentry->data = entry;
+ resultentry->ber = NULL;
}
}
/* }}} */
@@ -1021,6 +1026,7 @@
resultentry_next->id = resultentry->id;
zend_list_addref(resultentry->id);
resultentry_next->data = entry_next;
+ resultentry_next->ber = NULL;
}
}
/* }}} */
@@ -1091,8 +1097,9 @@
attribute = ldap_next_attribute(ldap,
ldap_result_entry, ber);
}
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
- if (ber != NULL)
+ if (ber != NULL) {
ber_free(ber, 0);
+ }
#endif
add_assoc_long(tmp1, "count", num_attrib);
@@ -1115,28 +1122,25 @@
}
/* }}} */
-/* {{{ proto string ldap_first_attribute(resource link, resource result_entry,
int ber)
+/* {{{ proto string ldap_first_attribute(resource link, resource result_entry)
Return first attribute */
PHP_FUNCTION(ldap_first_attribute)
{
- zval **link, **result_entry, **berp;
+ zval **link, **result_entry;
ldap_linkdata *ld;
ldap_resultentry *resultentry;
- BerElement *ber;
char *attribute;
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &link,
&result_entry, &berp) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &link,
&result_entry) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link",
le_link);
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1,
"ldap result entry", le_result_entry);
- if ((attribute = ldap_first_attribute(ld->link, resultentry->data,
&ber)) == NULL) {
+ if ((attribute = ldap_first_attribute(ld->link, resultentry->data,
&resultentry->ber)) == NULL) {
RETURN_FALSE;
} else {
- ZEND_REGISTER_RESOURCE(*berp, ber, le_ber_entry);
-
RETVAL_STRING(attribute, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(attribute);
@@ -1145,29 +1149,31 @@
}
/* }}} */
-/* {{{ proto string ldap_next_attribute(resource link, resource result_entry,
resource ber)
+/* {{{ proto string ldap_next_attribute(resource link, resource result_entry)
Get the next attribute in result */
PHP_FUNCTION(ldap_next_attribute)
{
- zval **link, **result_entry, **berp;
+ zval **link, **result_entry;
ldap_linkdata *ld;
ldap_resultentry *resultentry;
- BerElement *ber;
char *attribute;
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &link,
&result_entry, &berp) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &link,
&result_entry) == FAILURE) {
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, link, -1, "ldap link",
le_link);
ZEND_FETCH_RESOURCE(resultentry, ldap_resultentry *, result_entry, -1,
"ldap result entry", le_result_entry);
- ZEND_FETCH_RESOURCE(ber, BerElement *, berp, -1, "ldap ber entry",
le_ber_entry);
- if ((attribute = ldap_next_attribute(ld->link, resultentry->data, ber))
== NULL) {
+ if ((attribute = ldap_next_attribute(ld->link, resultentry->data,
resultentry->ber)) == NULL) {
+#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
+ if (resultentry->ber != NULL) {
+ ber_free(resultentry->ber, 0);
+ resultentry->ber = NULL;
+ }
+#endif
RETURN_FALSE;
} else {
- ZEND_REGISTER_RESOURCE(*berp, ber, le_ber_entry);
-
RETVAL_STRING(attribute, 1);
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
ldap_memfree(attribute);
@@ -1222,9 +1228,9 @@
attribute = ldap_next_attribute(ld->link, resultentry->data,
ber);
}
#if (LDAP_API_VERSION > 2000) || HAVE_NSLDAP || HAVE_ORALDAP_10 || WINDOWS
- if (ber != NULL) {
- ber_free(ber, 0);
- }
+ if (ber != NULL) {
+ ber_free(ber, 0);
+ }
#endif
add_assoc_long(return_value, "count", num_attrib);
http://cvs.php.net/viewvc.cgi/php-src/ext/ldap/php_ldap.h?r1=1.32.2.1.2.1&r2=1.32.2.1.2.2&diff_format=u
Index: php-src/ext/ldap/php_ldap.h
diff -u php-src/ext/ldap/php_ldap.h:1.32.2.1.2.1
php-src/ext/ldap/php_ldap.h:1.32.2.1.2.2
--- php-src/ext/ldap/php_ldap.h:1.32.2.1.2.1 Mon Jan 1 09:36:02 2007
+++ php-src/ext/ldap/php_ldap.h Fri Jul 13 01:24:16 2007
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_ldap.h,v 1.32.2.1.2.1 2007/01/01 09:36:02 sebastian Exp $ */
+/* $Id: php_ldap.h,v 1.32.2.1.2.2 2007/07/13 01:24:16 jani Exp $ */
#ifndef PHP_LDAP_H
#define PHP_LDAP_H
@@ -55,7 +55,6 @@
PHP_FUNCTION(ldap_get_attributes);
PHP_FUNCTION(ldap_get_values);
PHP_FUNCTION(ldap_get_values_len);
-PHP_FUNCTION(ber_free);
PHP_FUNCTION(ldap_get_dn);
PHP_FUNCTION(ldap_explode_dn);
PHP_FUNCTION(ldap_dn2ufn);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php