@@ -3350,8 +3350,10 @@ PHP_REDIS_API int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS,
3350
3350
}
3351
3351
if (numElems == -1 && redis_sock -> null_mbulk_as_null ) {
3352
3352
ZVAL_NULL (& z_multi_result );
3353
+ } else if (numElems < 1 ) {
3354
+ ZVAL_EMPTY_ARRAY (& z_multi_result );
3353
3355
} else {
3354
- array_init (& z_multi_result );
3356
+ array_init_size (& z_multi_result , numElems );
3355
3357
redis_mbulk_reply_loop (redis_sock , & z_multi_result , numElems , UNSERIALIZE_ALL );
3356
3358
}
3357
3359
@@ -3380,7 +3382,7 @@ redis_mbulk_reply_raw(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval
3380
3382
return FAILURE ;
3381
3383
}
3382
3384
zval z_multi_result ;
3383
- array_init (& z_multi_result ); /* pre-allocate array for multi's results. */
3385
+ array_init_size (& z_multi_result , numElems ); /* pre-allocate array for multi's results. */
3384
3386
3385
3387
redis_mbulk_reply_loop (redis_sock , & z_multi_result , numElems , UNSERIALIZE_NONE );
3386
3388
@@ -3409,14 +3411,18 @@ redis_mbulk_reply_double(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zv
3409
3411
return FAILURE ;
3410
3412
}
3411
3413
3412
- array_init (& z_multi_result );
3413
- for (i = 0 ; i < numElems ; ++ i ) {
3414
- if ((line = redis_sock_read (redis_sock , & len )) == NULL ) {
3415
- add_next_index_bool (& z_multi_result , 0 );
3416
- continue ;
3414
+ if (numElems < 1 ) {
3415
+ ZVAL_EMPTY_ARRAY (& z_multi_result );
3416
+ } else {
3417
+ array_init_size (& z_multi_result , numElems );
3418
+ for (i = 0 ; i < numElems ; ++ i ) {
3419
+ if ((line = redis_sock_read (redis_sock , & len )) == NULL ) {
3420
+ add_next_index_bool (& z_multi_result , 0 );
3421
+ continue ;
3422
+ }
3423
+ add_next_index_double (& z_multi_result , atof (line ));
3424
+ efree (line );
3417
3425
}
3418
- add_next_index_double (& z_multi_result , atof (line ));
3419
- efree (line );
3420
3426
}
3421
3427
3422
3428
if (IS_ATOMIC (redis_sock )) {
0 commit comments