@@ -3202,15 +3202,15 @@ PHP_FUNCTION(ldap_set_option)
3202
3202
/* {{{ Extract information from result */
3203
3203
PHP_FUNCTION (ldap_parse_result )
3204
3204
{
3205
- zval * link , * result , * errcode , * matcheddn , * errmsg , * referrals , * serverctrls ;
3205
+ zval * link , * result , * errcode , * matcheddn = NULL , * errmsg = NULL , * referrals = NULL , * serverctrls = NULL ;
3206
3206
ldap_linkdata * ld ;
3207
3207
ldap_resultdata * ldap_result ;
3208
3208
LDAPControl * * lserverctrls = NULL ;
3209
3209
char * * lreferrals , * * refp ;
3210
3210
char * lmatcheddn , * lerrmsg ;
3211
- int rc , lerrcode , myargcount = ZEND_NUM_ARGS () ;
3211
+ int rc , lerrcode ;
3212
3212
3213
- if (zend_parse_parameters (myargcount , "OOz|zzzz" , & link , ldap_link_ce , & result , ldap_result_ce , & errcode , & matcheddn , & errmsg , & referrals , & serverctrls ) != SUCCESS ) {
3213
+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "OOz|zzzz" , & link , ldap_link_ce , & result , ldap_result_ce , & errcode , & matcheddn , & errmsg , & referrals , & serverctrls ) != SUCCESS ) {
3214
3214
RETURN_THROWS ();
3215
3215
}
3216
3216
@@ -3221,10 +3221,10 @@ PHP_FUNCTION(ldap_parse_result)
3221
3221
VERIFY_LDAP_RESULT_OPEN (ldap_result );
3222
3222
3223
3223
rc = ldap_parse_result (ld -> link , ldap_result -> result , & lerrcode ,
3224
- myargcount > 3 ? & lmatcheddn : NULL ,
3225
- myargcount > 4 ? & lerrmsg : NULL ,
3226
- myargcount > 5 ? & lreferrals : NULL ,
3227
- myargcount > 6 ? & lserverctrls : NULL ,
3224
+ matcheddn ? & lmatcheddn : NULL ,
3225
+ errmsg ? & lerrmsg : NULL ,
3226
+ referrals ? & lreferrals : NULL ,
3227
+ serverctrls ? & lserverctrls : NULL ,
3228
3228
0 );
3229
3229
if (rc != LDAP_SUCCESS ) {
3230
3230
php_error_docref (NULL , E_WARNING , "Unable to parse result: %s" , ldap_err2string (rc ));
@@ -3233,41 +3233,40 @@ PHP_FUNCTION(ldap_parse_result)
3233
3233
3234
3234
ZEND_TRY_ASSIGN_REF_LONG (errcode , lerrcode );
3235
3235
3236
- /* Reverse -> fall through */
3237
- switch (myargcount ) {
3238
- case 7 :
3239
- _php_ldap_controls_to_array (ld -> link , lserverctrls , serverctrls , 0 );
3240
- ZEND_FALLTHROUGH ;
3241
- case 6 :
3242
- referrals = zend_try_array_init (referrals );
3243
- if (!referrals ) {
3244
- RETURN_THROWS ();
3245
- }
3246
- if (lreferrals != NULL ) {
3247
- refp = lreferrals ;
3248
- while (* refp ) {
3249
- add_next_index_string (referrals , * refp );
3250
- refp ++ ;
3251
- }
3252
- ldap_memvfree ((void * * )lreferrals );
3253
- }
3254
- ZEND_FALLTHROUGH ;
3255
- case 5 :
3256
- if (lerrmsg == NULL ) {
3257
- ZEND_TRY_ASSIGN_REF_EMPTY_STRING (errmsg );
3258
- } else {
3259
- ZEND_TRY_ASSIGN_REF_STRING (errmsg , lerrmsg );
3260
- ldap_memfree (lerrmsg );
3261
- }
3262
- ZEND_FALLTHROUGH ;
3263
- case 4 :
3264
- if (lmatcheddn == NULL ) {
3265
- ZEND_TRY_ASSIGN_REF_EMPTY_STRING (matcheddn );
3266
- } else {
3267
- ZEND_TRY_ASSIGN_REF_STRING (matcheddn , lmatcheddn );
3268
- ldap_memfree (lmatcheddn );
3236
+ if (serverctrls ) {
3237
+ _php_ldap_controls_to_array (ld -> link , lserverctrls , serverctrls , 0 );
3238
+ }
3239
+ if (referrals ) {
3240
+ referrals = zend_try_array_init (referrals );
3241
+ if (!referrals ) {
3242
+ RETURN_THROWS ();
3243
+ }
3244
+ if (lreferrals != NULL ) {
3245
+ refp = lreferrals ;
3246
+ while (* refp ) {
3247
+ add_next_index_string (referrals , * refp );
3248
+ refp ++ ;
3269
3249
}
3250
+ ldap_memvfree ((void * * )lreferrals );
3251
+ }
3270
3252
}
3253
+ if (errmsg ) {
3254
+ if (lerrmsg == NULL ) {
3255
+ ZEND_TRY_ASSIGN_REF_EMPTY_STRING (errmsg );
3256
+ } else {
3257
+ ZEND_TRY_ASSIGN_REF_STRING (errmsg , lerrmsg );
3258
+ ldap_memfree (lerrmsg );
3259
+ }
3260
+ }
3261
+ if (matcheddn ) {
3262
+ if (lmatcheddn == NULL ) {
3263
+ ZEND_TRY_ASSIGN_REF_EMPTY_STRING (matcheddn );
3264
+ } else {
3265
+ ZEND_TRY_ASSIGN_REF_STRING (matcheddn , lmatcheddn );
3266
+ ldap_memfree (lmatcheddn );
3267
+ }
3268
+ }
3269
+
3271
3270
RETURN_TRUE ;
3272
3271
}
3273
3272
/* }}} */
0 commit comments