@@ -166,7 +166,7 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array,
166
166
}
167
167
} else if (strcmp (ctrl -> ldctl_oid , LDAP_CONTROL_PAGEDRESULTS ) == 0 ) {
168
168
int lestimated , rc ;
169
- struct berval lcookie = { 0 , NULL };
169
+ struct berval lcookie = { 0L , NULL };
170
170
zval value ;
171
171
172
172
if (ctrl -> ldctl_value .bv_len ) {
@@ -308,7 +308,7 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
308
308
}
309
309
310
310
BerElement * ber = NULL ;
311
- struct berval control_value = { 0 , NULL };
311
+ struct berval control_value = { 0L , NULL };
312
312
int control_value_alloc = 0 ;
313
313
314
314
if ((val = zend_hash_str_find (Z_ARRVAL_P (array ), "value" , sizeof ("value" ) - 1 )) != NULL ) {
@@ -323,7 +323,7 @@ static int _php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, zval* arra
323
323
} else if (strcmp (ZSTR_VAL (control_oid ), LDAP_CONTROL_PAGEDRESULTS ) == 0 ) {
324
324
zval * tmp ;
325
325
int pagesize = 1 ;
326
- struct berval cookie = { 0 , NULL };
326
+ struct berval cookie = { 0L , NULL };
327
327
if ((tmp = zend_hash_str_find (Z_ARRVAL_P (val ), "size" , sizeof ("size" ) - 1 )) != NULL ) {
328
328
pagesize = zval_get_long (tmp );
329
329
}
@@ -1447,7 +1447,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1447
1447
zend_string * ldap_filter = NULL , * ldap_base_dn = NULL ;
1448
1448
char * * ldap_attrs = NULL ;
1449
1449
ldap_linkdata * ld = NULL ;
1450
- LDAPMessage * ldap_res ;
1450
+ LDAPMessage * ldap_res = NULL ;
1451
1451
LDAPControl * * lserverctrls = NULL ;
1452
1452
int ldap_attrsonly = 0 , ldap_sizelimit = -1 , ldap_timelimit = -1 , ldap_deref = -1 ;
1453
1453
int old_ldap_sizelimit = -1 , old_ldap_timelimit = -1 , old_ldap_deref = -1 ;
@@ -1647,6 +1647,13 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1647
1647
&& errno != LDAP_REFERRAL
1648
1648
#endif
1649
1649
) {
1650
+ /* ldap_res should be freed with ldap_msgfree() regardless of return
1651
+ * value of ldap_search_ext_s()
1652
+ * see: https://linux.die.net/man/3/ldap_search_ext_s
1653
+ */
1654
+ if (ldap_res != NULL ) {
1655
+ ldap_msgfree (ldap_res );
1656
+ }
1650
1657
php_error_docref (NULL , E_WARNING , "Search: %s" , ldap_err2string (errno ));
1651
1658
ret = 0 ;
1652
1659
} else {
@@ -3968,7 +3975,7 @@ PHP_FUNCTION(ldap_control_paged_result)
3968
3975
zval * link ;
3969
3976
char * cookie = NULL ;
3970
3977
size_t cookie_len = 0 ;
3971
- struct berval lcookie = { 0 , NULL };
3978
+ struct berval lcookie = { 0L , NULL };
3972
3979
ldap_linkdata * ld ;
3973
3980
LDAP * ldap ;
3974
3981
BerElement * ber = NULL ;
0 commit comments