From: Arran Cudbard-Bell Date: Thu, 7 Mar 2019 05:22:32 +0000 (+0800) Subject: Don't leak reply objects the any time the script needs to be loaded X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f77fff082facd60bc0ec695a07a863d01a23f6c9;p=thirdparty%2Ffreeradius-server.git Don't leak reply objects the any time the script needs to be loaded This is a pretty minor leak as the scripts are usually only loaded on startup, but if someone kept trashing the script cache, this could become an issue. --- diff --git a/src/modules/rlm_redis_ippool/rlm_redis_ippool.c b/src/modules/rlm_redis_ippool/rlm_redis_ippool.c index 09ae431604e..57c521460c0 100644 --- a/src/modules/rlm_redis_ippool/rlm_redis_ippool.c +++ b/src/modules/rlm_redis_ippool/rlm_redis_ippool.c @@ -460,6 +460,10 @@ static fr_redis_rcode_t ippool_script(redisReply **out, REQUEST *request, fr_red *out = NULL; +#ifndef NDEBUG + memset(replies, 0, sizeof(replies)); +#endif + va_start(ap, cmd); for (s_ret = fr_redis_cluster_state_init(&state, &conn, cluster, request, key, key_len, false); @@ -481,6 +485,11 @@ static fr_redis_rcode_t ippool_script(redisReply **out, REQUEST *request, fr_red conn); if (status != REDIS_RCODE_NO_SCRIPT) continue; + /* + * Clear out the existing reply + */ + fr_redis_pipeline_free(replies, reply_cnt); + /* * Last command failed with NOSCRIPT, this means * we have to send the Lua script up to the node @@ -665,7 +674,7 @@ static ippool_rcode_t redis_ippool_allocate(rlm_redis_ippool_t const *inst, REQU tmp.type = FR_TYPE_UINT32; if (fr_value_box_cast(NULL, &ip_map.rhs->tmpl_value, FR_TYPE_IPV4_ADDR, - NULL, &tmp)) { + NULL, &tmp)) { RPEDEBUG("Failed converting integer to IPv4 address"); ret = IPPOOL_RCODE_FAIL; goto finish;