@@ -1403,10 +1403,11 @@ static void php_set_opts(LDAP *ldap, int sizelimit, int timelimit, int deref, in
1403
1403
static void php_ldap_do_search (INTERNAL_FUNCTION_PARAMETERS , int scope )
1404
1404
{
1405
1405
zval * link , * attrs = NULL , * serverctrls = NULL ;
1406
- zend_string * base_dn_str , * filter_str ;
1407
- HashTable * base_dn_ht , * filter_ht ;
1406
+ HashTable * base_dn_ht = NULL ;
1407
+ zend_string * base_dn_str = NULL ;
1408
+ HashTable * filter_ht = NULL ;
1409
+ zend_string * filter_str = NULL ;
1408
1410
zend_long attrsonly , sizelimit , timelimit , deref ;
1409
- zend_string * ldap_filter = NULL , * ldap_base_dn = NULL ;
1410
1411
char * * ldap_attrs = NULL ;
1411
1412
ldap_linkdata * ld = NULL ;
1412
1413
ldap_resultdata * result ;
@@ -1485,6 +1486,8 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1485
1486
1486
1487
/* parallel search? */
1487
1488
if (Z_TYPE_P (link ) == IS_ARRAY ) {
1489
+ const zend_string * ldap_base_dn = NULL ;
1490
+ const zend_string * ldap_filter = NULL ;
1488
1491
uint32_t num_links = zend_hash_num_elements (Z_ARRVAL_P (link ));
1489
1492
if (num_links == 0 ) {
1490
1493
zend_argument_must_not_be_empty_error (1 );
@@ -1510,7 +1513,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1510
1513
ret = 0 ;
1511
1514
goto cleanup ;
1512
1515
}
1513
- ldap_base_dn = zend_string_copy ( base_dn_str ) ;
1516
+ ldap_base_dn = base_dn_str ;
1514
1517
}
1515
1518
1516
1519
uint32_t num_filters = 0 ; /* If 0 this means we are working with a unique base dn */
@@ -1531,7 +1534,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1531
1534
ret = 0 ;
1532
1535
goto cleanup ;
1533
1536
}
1534
- ldap_filter = zend_string_copy ( filter_str ) ;
1537
+ ldap_filter = filter_str ;
1535
1538
}
1536
1539
1537
1540
int * rcs ;
@@ -1563,7 +1566,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1563
1566
ret = 0 ;
1564
1567
goto cleanup_parallel ;
1565
1568
}
1566
- ldap_base_dn = zend_string_copy ( Z_STR_P (base_dn_zv ) );
1569
+ ldap_base_dn = Z_STR_P (base_dn_zv );
1567
1570
if (zend_str_has_nul_byte (ldap_base_dn )) {
1568
1571
zend_argument_value_error (2 , "must not contain null bytes" );
1569
1572
ret = 0 ;
@@ -1578,7 +1581,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1578
1581
ret = 0 ;
1579
1582
goto cleanup_parallel ;
1580
1583
}
1581
- ldap_filter = zend_string_copy ( Z_STR_P (filter_zv ) );
1584
+ ldap_filter = Z_STR_P (filter_zv );
1582
1585
if (zend_str_has_nul_byte (ldap_filter )) {
1583
1586
zend_argument_value_error (3 , "must not contain null bytes" );
1584
1587
ret = 0 ;
@@ -1640,14 +1643,12 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1640
1643
ret = 0 ;
1641
1644
goto cleanup ;
1642
1645
}
1643
- ldap_base_dn = zend_string_copy (base_dn_str );
1644
1646
1645
1647
if (!filter_str ) {
1646
1648
zend_argument_type_error (3 , "must be of type string when argument #1 ($ldap) is an LDAP instance" );
1647
1649
ret = 0 ;
1648
1650
goto cleanup ;
1649
1651
}
1650
- ldap_filter = zend_string_copy (filter_str );
1651
1652
1652
1653
if (serverctrls ) {
1653
1654
lserverctrls = _php_ldap_controls_from_array (ld -> link , serverctrls , 9 );
@@ -1660,7 +1661,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1660
1661
php_set_opts (ld -> link , ldap_sizelimit , ldap_timelimit , ldap_deref , & old_ldap_sizelimit , & old_ldap_timelimit , & old_ldap_deref );
1661
1662
1662
1663
/* Run the actual search */
1663
- ldap_errno = ldap_search_ext_s (ld -> link , ZSTR_VAL (ldap_base_dn ), scope , ZSTR_VAL (ldap_filter ), ldap_attrs , ldap_attrsonly , lserverctrls , NULL , NULL , ldap_sizelimit , & ldap_res );
1664
+ ldap_errno = ldap_search_ext_s (ld -> link , ZSTR_VAL (base_dn_str ), scope , ZSTR_VAL (filter_str ), ldap_attrs , ldap_attrsonly , lserverctrls , NULL , NULL , ldap_sizelimit , & ldap_res );
1664
1665
1665
1666
if (ldap_errno != LDAP_SUCCESS
1666
1667
&& ldap_errno != LDAP_SIZELIMIT_EXCEEDED
@@ -1700,12 +1701,6 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1700
1701
/* Restoring previous options */
1701
1702
php_set_opts (ld -> link , old_ldap_sizelimit , old_ldap_timelimit , old_ldap_deref , & ldap_sizelimit , & ldap_timelimit , & ldap_deref );
1702
1703
}
1703
- if (ldap_filter ) {
1704
- zend_string_release (ldap_filter );
1705
- }
1706
- if (ldap_base_dn ) {
1707
- zend_string_release (ldap_base_dn );
1708
- }
1709
1704
if (ldap_attrs != NULL ) {
1710
1705
efree (ldap_attrs );
1711
1706
}
0 commit comments