Skip to content

Commit 14a41a6

Browse files
committed
Move ra->count initialization to ra_load_hosts
1 parent a13bf17 commit 14a41a6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

redis_array_impl.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ ra_load_hosts(RedisArray *ra, HashTable *hosts, long retry_interval, zend_bool b
4646
{
4747
if ((zend_hash_get_current_data(hosts, (void **) &zpData) == FAILURE) || (Z_TYPE_PP(zpData) != IS_STRING))
4848
{
49+
for(i=0;i<ra->count;i++) {
50+
zval_dtor(ra->redis[i]);
51+
efree(ra->redis[i]);
52+
efree(ra->hosts[i]);
53+
}
54+
efree(ra->redis);
55+
efree(ra->hosts);
56+
zval_dtor(&z_cons);
4957
efree(ra);
5058
return NULL;
5159
}
@@ -87,7 +95,7 @@ ra_load_hosts(RedisArray *ra, HashTable *hosts, long retry_interval, zend_bool b
8795
#endif
8896
add_property_resource(ra->redis[i], "socket", id);
8997

90-
i++;
98+
ra->count = ++i;
9199
}
92100

93101
return ra;
@@ -330,7 +338,7 @@ ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev
330338
RedisArray *ra = emalloc(sizeof(RedisArray));
331339
ra->hosts = emalloc(count * sizeof(char*));
332340
ra->redis = emalloc(count * sizeof(zval*));
333-
ra->count = count;
341+
ra->count = 0;
334342
ra->z_fun = NULL;
335343
ra->z_dist = NULL;
336344
ra->z_multi_exec = NULL;

0 commit comments

Comments
 (0)