@@ -3202,15 +3202,15 @@ PHP_FUNCTION(ldap_set_option)
32023202/* {{{ Extract information from result */
32033203PHP_FUNCTION (ldap_parse_result )
32043204{
3205- zval * link , * result , * errcode , * matcheddn , * errmsg , * referrals , * serverctrls ;
3205+ zval * link , * result , * errcode , * matcheddn = NULL , * errmsg = NULL , * referrals = NULL , * serverctrls = NULL ;
32063206 ldap_linkdata * ld ;
32073207 ldap_resultdata * ldap_result ;
32083208 LDAPControl * * lserverctrls = NULL ;
32093209 char * * lreferrals , * * refp ;
32103210 char * lmatcheddn , * lerrmsg ;
3211- int rc , lerrcode , myargcount = ZEND_NUM_ARGS () ;
3211+ int rc , lerrcode ;
32123212
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 ) {
32143214 RETURN_THROWS ();
32153215 }
32163216
@@ -3221,10 +3221,10 @@ PHP_FUNCTION(ldap_parse_result)
32213221 VERIFY_LDAP_RESULT_OPEN (ldap_result );
32223222
32233223 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 ,
32283228 0 );
32293229 if (rc != LDAP_SUCCESS ) {
32303230 php_error_docref (NULL , E_WARNING , "Unable to parse result: %s" , ldap_err2string (rc ));
@@ -3233,41 +3233,40 @@ PHP_FUNCTION(ldap_parse_result)
32333233
32343234 ZEND_TRY_ASSIGN_REF_LONG (errcode , lerrcode );
32353235
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 ++ ;
32693249 }
3250+ ldap_memvfree ((void * * )lreferrals );
3251+ }
32703252 }
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+
32713270 RETURN_TRUE ;
32723271}
32733272/* }}} */
0 commit comments