Skip to content

Commit aaca9a2

Browse files
committed
fixing ldap memory leaks php#4
1 parent f8d8942 commit aaca9a2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

ext/ldap/ldap.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4318,6 +4318,13 @@ PHP_FUNCTION(ldap_exop_passwd)
43184318
goto cleanup;
43194319
}
43204320

4321+
rc = ldap_parse_result(ld->link, ldap_res, &err, NULL, &errmsg, NULL, (myargcount > 4 ? &lserverctrls : NULL), 0); /* memleak: ??? */
4322+
if( rc != LDAP_SUCCESS ) {
4323+
php_error_docref(NULL, E_WARNING, "Passwd modify extended operation failed: %s (%d)", ldap_err2string(rc), rc);
4324+
RETVAL_FALSE;
4325+
goto cleanup;
4326+
}
4327+
43214328
if (lnewpw.bv_len == 0) {
43224329
if (lgenpasswd.bv_len == 0) {
43234330
RETVAL_EMPTY_STRING();
@@ -4329,14 +4336,8 @@ PHP_FUNCTION(ldap_exop_passwd)
43294336
} else {
43304337
php_error_docref(NULL, E_WARNING, "Passwd modify extended operation failed: %s (%d)", (errmsg ? errmsg : ldap_err2string(err)), err);
43314338
RETVAL_FALSE;
4332-
goto cleanup;
4333-
}
4334-
4335-
rc = ldap_parse_result(ld->link, ldap_res, &err, NULL, &errmsg, NULL, (myargcount > 4 ? &lserverctrls : NULL), 0); /* memleak: ??? */
4336-
if( rc != LDAP_SUCCESS ) {
4337-
php_error_docref(NULL, E_WARNING, "Passwd modify extended operation failed: %s (%d)", ldap_err2string(rc), rc);
4338-
RETVAL_FALSE;
4339-
goto cleanup;
4339+
/* don't "goto cleanup" here, we need _php_ldap_controls_to_array() as it
4340+
* releasesthe lserverctrls */
43404341
}
43414342

43424343
if (myargcount > 4) {

0 commit comments

Comments
 (0)