@@ -545,8 +545,9 @@ PHP_REDIS_API int redis_subscribe_response(INTERNAL_FUNCTION_PARAMETERS,
545
545
/* Multibulk response, {[pattern], type, channel, payload } */
546
546
while (redis_sock -> subs [i ]) {
547
547
zval z_ret , z_args [4 ], * z_type , * z_chan , * z_pat = NULL , * z_data ;
548
- HashTable * ht_tab ;
549
548
int tab_idx = 1 , is_pmsg = 0 ;
549
+ HashTable * ht_tab ;
550
+ zend_string * zs ;
550
551
551
552
ZVAL_NULL (& z_resp );
552
553
if (!redis_sock_read_multibulk_reply_zval (redis_sock , & z_resp )) {
@@ -573,22 +574,26 @@ PHP_REDIS_API int redis_subscribe_response(INTERNAL_FUNCTION_PARAMETERS,
573
574
}
574
575
575
576
// Extract pattern if it's a pmessage
576
- if (is_pmsg ) {
577
- if ((z_pat = zend_hash_index_find (ht_tab , tab_idx ++ )) == NULL ) {
577
+ if (is_pmsg ) {
578
+ z_pat = zend_hash_index_find (ht_tab , tab_idx ++ );
579
+ if (z_pat == NULL || Z_TYPE_P (z_pat ) != IS_STRING )
578
580
goto failure ;
579
- }
580
581
}
581
582
582
- // Extract channel and data
583
- if ((z_chan = zend_hash_index_find (ht_tab , tab_idx ++ )) == NULL ||
584
- (z_data = zend_hash_index_find (ht_tab , tab_idx ++ )) == NULL
585
- ) {
583
+ /* Extract channel */
584
+ z_chan = zend_hash_index_find (ht_tab , tab_idx ++ );
585
+ if (z_chan == NULL || Z_TYPE_P (z_chan ) != IS_STRING )
586
586
goto failure ;
587
- }
588
587
589
- if ((cb = zend_hash_str_find_ptr (redis_sock -> subs [i ], Z_STRVAL_P (z_chan ), Z_STRLEN_P (z_chan ))) == NULL ) {
588
+ /* Finally, extract data */
589
+ z_data = zend_hash_index_find (ht_tab , tab_idx ++ );
590
+ if (z_data == NULL )
591
+ goto failure ;
592
+
593
+ /* Find our callback, either by channel or pattern string */
594
+ zs = z_pat != NULL ? Z_STR_P (z_pat ) : Z_STR_P (z_chan );
595
+ if ((cb = zend_hash_find_ptr (redis_sock -> subs [i ], zs )) == NULL )
590
596
goto failure ;
591
- }
592
597
593
598
// Different args for SUBSCRIBE and PSUBSCRIBE
594
599
z_args [0 ] = * getThis ();
0 commit comments