File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -463,7 +463,8 @@ redis_sock_read_multibulk_reply_zval(INTERNAL_FUNCTION_PARAMETERS,
463
463
/**
464
464
* redis_sock_read_bulk_reply
465
465
*/
466
- PHP_REDIS_API char * redis_sock_read_bulk_reply (RedisSock * redis_sock , int bytes TSRMLS_DC )
466
+ PHP_REDIS_API char *
467
+ redis_sock_read_bulk_reply (RedisSock * redis_sock , int bytes TSRMLS_DC )
467
468
{
468
469
int offset = 0 ;
469
470
size_t got ;
@@ -478,17 +479,19 @@ PHP_REDIS_API char *redis_sock_read_bulk_reply(RedisSock *redis_sock, int bytes
478
479
while (offset < bytes ) {
479
480
got = php_stream_read (redis_sock -> stream , reply + offset ,
480
481
bytes - offset );
481
- if (got <= 0 ) {
482
- /* Error or EOF */
483
- zend_throw_exception (redis_exception_ce ,
484
- "socket error on read socket" , 0 TSRMLS_CC );
485
- break ;
486
- }
482
+ if (got == 0 ) break ;
487
483
offset += got ;
488
484
}
485
+ if (offset < bytes ) {
486
+ /* Error or EOF */
487
+ zend_throw_exception (redis_exception_ce ,
488
+ "socket error on read socket" , 0 TSRMLS_CC );
489
+ efree (reply );
490
+ return NULL ;
491
+ }
489
492
php_stream_read (redis_sock -> stream , c , 2 );
490
493
491
- reply [bytes ] = 0 ;
494
+ reply [bytes ] = '\0' ;
492
495
return reply ;
493
496
}
494
497
You can’t perform that action at this time.
0 commit comments