diff options
author | michael-grunder <michael.grunder@gmail.com> | 2014-06-14 23:06:32 +0400 |
---|---|---|
committer | michael-grunder <michael.grunder@gmail.com> | 2015-05-06 01:01:34 +0300 |
commit | cb1e84aa9093d6e6e451b5d49616ae176425c052 (patch) | |
tree | aed88e890454b015e40be3b400289570cfc9ac4c /cluster_library.c | |
parent | 55e5d491269d4b4e0b64ea2dcd89c980769d2573 (diff) |
Fix memory leaks for (P)SUBSCRIBE/(P)UNSUBSCRIBE
Diffstat (limited to 'cluster_library.c')
-rw-r--r-- | cluster_library.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/cluster_library.c b/cluster_library.c index 6524d762..5da2e87d 100644 --- a/cluster_library.c +++ b/cluster_library.c @@ -1389,6 +1389,7 @@ PHPAPI void cluster_sub_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, } zval_dtor(z_tab); + efree(z_tab); pull = 1; } @@ -1465,6 +1466,9 @@ PHPAPI void cluster_sub_resp(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, break; } + // If we have a return value, free it + if(z_ret) zval_ptr_dtor(&z_ret); + zval_dtor(z_tab); efree(z_tab); } @@ -1489,12 +1493,13 @@ PHPAPI void cluster_unsub_resp(INTERNAL_FUNCTION_PARAMETERS, { subscribeContext *sctx = (subscribeContext*)ctx; zval *z_tab, **z_chan, **z_flag; - int pull = 0; + int pull = 0, argc = sctx->argc; + efree(sctx); array_init(return_value); // Consume each response - while(sctx->argc--) { + while(argc--) { z_tab = cluster_zval_mbulk_resp(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, pull, mbulk_resp_loop_raw); @@ -1502,20 +1507,20 @@ PHPAPI void cluster_unsub_resp(INTERNAL_FUNCTION_PARAMETERS, if(!z_tab || zend_hash_index_find(Z_ARRVAL_P(z_tab), 1, (void**)&z_chan)==FAILURE) { + if(z_tab) { + zval_dtor(z_tab); + efree(z_tab); + } zval_dtor(return_value); RETURN_FALSE; } // Find the flag for this channel/pattern if(zend_hash_index_find(Z_ARRVAL_P(z_tab), 2, (void**)&z_flag) - ==FAILURE) + ==FAILURE || Z_STRLEN_PP(z_flag)!=2) { - zval_dtor(return_value); - RETURN_FALSE; - } - - // Sanity check - if(Z_STRLEN_PP(z_flag) != 2) { + zval_dtor(z_tab); + efree(z_tab); zval_dtor(return_value); RETURN_FALSE; } @@ -1526,6 +1531,7 @@ PHPAPI void cluster_unsub_resp(INTERNAL_FUNCTION_PARAMETERS, // Add result add_assoc_bool(return_value, Z_STRVAL_PP(z_chan), flag[1]=='1'); + zval_dtor(z_tab); efree(z_tab); pull = 1; } |