@@ -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 );
@@ -1516,7 +1519,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1516
1519
ret = 0 ;
1517
1520
goto cleanup ;
1518
1521
}
1519
- ldap_base_dn = zend_string_copy ( base_dn_str ) ;
1522
+ ldap_base_dn = base_dn_str ;
1520
1523
}
1521
1524
1522
1525
uint32_t num_filters = 0 ; /* If 0 this means we are working with a unique base dn */
@@ -1538,7 +1541,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1538
1541
ret = 0 ;
1539
1542
goto cleanup ;
1540
1543
}
1541
- ldap_filter = zend_string_copy ( filter_str ) ;
1544
+ ldap_filter = filter_str ;
1542
1545
}
1543
1546
1544
1547
int * rcs ;
@@ -1570,7 +1573,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1570
1573
ret = 0 ;
1571
1574
goto cleanup_parallel ;
1572
1575
}
1573
- ldap_base_dn = zend_string_copy ( Z_STR_P (base_dn_zv ) );
1576
+ ldap_base_dn = Z_STR_P (base_dn_zv );
1574
1577
if (zend_str_has_nul_byte (ldap_base_dn )) {
1575
1578
zend_argument_value_error (2 , "must not contain null bytes" );
1576
1579
ret = 0 ;
@@ -1585,7 +1588,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1585
1588
ret = 0 ;
1586
1589
goto cleanup_parallel ;
1587
1590
}
1588
- ldap_filter = zend_string_copy ( Z_STR_P (filter_zv ) );
1591
+ ldap_filter = Z_STR_P (filter_zv );
1589
1592
if (zend_str_has_nul_byte (ldap_filter )) {
1590
1593
zend_argument_value_error (3 , "must not contain null bytes" );
1591
1594
ret = 0 ;
@@ -1647,14 +1650,12 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1647
1650
ret = 0 ;
1648
1651
goto cleanup ;
1649
1652
}
1650
- ldap_base_dn = zend_string_copy (base_dn_str );
1651
1653
1652
1654
if (!filter_str ) {
1653
1655
zend_argument_type_error (3 , "must be of type string when argument #1 ($ldap) is an LDAP instance" );
1654
1656
ret = 0 ;
1655
1657
goto cleanup ;
1656
1658
}
1657
- ldap_filter = zend_string_copy (filter_str );
1658
1659
1659
1660
if (serverctrls ) {
1660
1661
lserverctrls = _php_ldap_controls_from_array (ld -> link , serverctrls , 9 );
@@ -1667,7 +1668,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1667
1668
php_set_opts (ld -> link , ldap_sizelimit , ldap_timelimit , ldap_deref , & old_ldap_sizelimit , & old_ldap_timelimit , & old_ldap_deref );
1668
1669
1669
1670
/* Run the actual search */
1670
- 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 );
1671
+ 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 );
1671
1672
1672
1673
if (ldap_errno != LDAP_SUCCESS
1673
1674
&& ldap_errno != LDAP_SIZELIMIT_EXCEEDED
@@ -1707,12 +1708,6 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
1707
1708
/* Restoring previous options */
1708
1709
php_set_opts (ld -> link , old_ldap_sizelimit , old_ldap_timelimit , old_ldap_deref , & ldap_sizelimit , & ldap_timelimit , & ldap_deref );
1709
1710
}
1710
- if (ldap_filter ) {
1711
- zend_string_release (ldap_filter );
1712
- }
1713
- if (ldap_base_dn ) {
1714
- zend_string_release (ldap_base_dn );
1715
- }
1716
1711
if (ldap_attrs != NULL ) {
1717
1712
efree (ldap_attrs );
1718
1713
}
0 commit comments