Skip to content

Commit a107c9f

Browse files
Fix a couple of memory leaks in Redis/RedisCluster
Addresses phpredis#1701
1 parent 2d39b48 commit a107c9f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cluster_library.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,6 +2448,8 @@ PHP_REDIS_API void cluster_mbulk_mget_resp(INTERNAL_FUNCTION_PARAMETERS,
24482448
} else {
24492449
add_next_index_zval(&c->multi_resp, mctx->z_multi);
24502450
}
2451+
2452+
efree(mctx->z_multi);
24512453
}
24522454

24532455
// Clean up this context item

redis_commands.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4083,13 +4083,14 @@ void redis_unserialize_handler(INTERNAL_FUNCTION_PARAMETERS,
40834083
// Just return the value that was passed to us
40844084
RETURN_STRINGL(value, value_len);
40854085
}
4086-
zval zv, *z_ret = &zv;
4087-
if (!redis_unserialize(redis_sock, value, value_len, z_ret)) {
4086+
4087+
zval z_ret;
4088+
if (!redis_unserialize(redis_sock, value, value_len, &z_ret)) {
40884089
// Badly formed input, throw an exception
40894090
zend_throw_exception(ex, "Invalid serialized data, or unserialization error", 0);
40904091
RETURN_FALSE;
40914092
}
4092-
RETURN_ZVAL(z_ret, 1, 0);
4093+
RETURN_ZVAL(&z_ret, 0, 0);
40934094
}
40944095

40954096
/* vim: set tabstop=4 softtabstop=4 expandtab shiftwidth=4: */

0 commit comments

Comments
 (0)