@@ -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 ;
@@ -1486,6 +1487,8 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1486
1487
1487
1488
/* parallel search? */
1488
1489
if (Z_TYPE_P (link ) == IS_ARRAY ) {
1490
+ const zend_string * ldap_base_dn = NULL ;
1491
+ const zend_string * ldap_filter = NULL ;
1489
1492
uint32_t num_links = zend_hash_num_elements (Z_ARRVAL_P (link ));
1490
1493
if (num_links == 0 ) {
1491
1494
zend_argument_must_not_be_empty_error (1 );
@@ -1517,7 +1520,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1517
1520
ret = 0 ;
1518
1521
goto cleanup ;
1519
1522
}
1520
- ldap_base_dn = zend_string_copy ( base_dn_str ) ;
1523
+ ldap_base_dn = base_dn_str ;
1521
1524
}
1522
1525
1523
1526
uint32_t num_filters = 0 ; /* If 0 this means we are working with a unique base dn */
@@ -1539,7 +1542,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1539
1542
ret = 0 ;
1540
1543
goto cleanup ;
1541
1544
}
1542
- ldap_filter = zend_string_copy ( filter_str ) ;
1545
+ ldap_filter = filter_str ;
1543
1546
}
1544
1547
1545
1548
int * rcs ;
@@ -1573,7 +1576,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1573
1576
ret = 0 ;
1574
1577
goto cleanup_parallel ;
1575
1578
}
1576
- ldap_base_dn = zend_string_copy ( Z_STR_P (base_dn_zv ) );
1579
+ ldap_base_dn = Z_STR_P (base_dn_zv );
1577
1580
if (zend_str_has_nul_byte (ldap_base_dn )) {
1578
1581
zend_argument_value_error (2 , "must not contain null bytes" );
1579
1582
ret = 0 ;
@@ -1589,7 +1592,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1589
1592
ret = 0 ;
1590
1593
goto cleanup_parallel ;
1591
1594
}
1592
- ldap_filter = zend_string_copy ( Z_STR_P (filter_zv ) );
1595
+ ldap_filter = Z_STR_P (filter_zv );
1593
1596
if (zend_str_has_nul_byte (ldap_filter )) {
1594
1597
zend_argument_value_error (3 , "must not contain null bytes" );
1595
1598
ret = 0 ;
@@ -1651,14 +1654,12 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1651
1654
ret = 0 ;
1652
1655
goto cleanup ;
1653
1656
}
1654
- ldap_base_dn = zend_string_copy (base_dn_str );
1655
1657
1656
1658
if (!filter_str ) {
1657
1659
zend_argument_type_error (3 , "must be of type string when argument #1 ($ldap) is an LDAP instance" );
1658
1660
ret = 0 ;
1659
1661
goto cleanup ;
1660
1662
}
1661
- ldap_filter = zend_string_copy (filter_str );
1662
1663
1663
1664
if (serverctrls ) {
1664
1665
lserverctrls = _php_ldap_controls_from_array (ld -> link , serverctrls , 9 );
@@ -1671,7 +1672,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1671
1672
php_set_opts (ld -> link , ldap_sizelimit , ldap_timelimit , ldap_deref , & old_ldap_sizelimit , & old_ldap_timelimit , & old_ldap_deref );
1672
1673
1673
1674
/* Run the actual search */
1674
- 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 );
1675
+ 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 );
1675
1676
1676
1677
if (ldap_errno != LDAP_SUCCESS
1677
1678
&& ldap_errno != LDAP_SIZELIMIT_EXCEEDED
@@ -1711,12 +1712,6 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1711
1712
/* Restoring previous options */
1712
1713
php_set_opts (ld -> link , old_ldap_sizelimit , old_ldap_timelimit , old_ldap_deref , & ldap_sizelimit , & ldap_timelimit , & ldap_deref );
1713
1714
}
1714
- if (ldap_filter ) {
1715
- zend_string_release (ldap_filter );
1716
- }
1717
- if (ldap_base_dn ) {
1718
- zend_string_release (ldap_base_dn );
1719
- }
1720
1715
if (ldap_attrs != NULL ) {
1721
1716
efree (ldap_attrs );
1722
1717
}
0 commit comments