From: Christopher Faulet Date: Fri, 7 Aug 2020 12:00:23 +0000 (+0200) Subject: BUG/MINOR: converters: Store the sink in an arg pointer for debug() converter X-Git-Tag: v2.3-dev3~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b45bf8eb70789264b9fd38fd6c1bc1c1c723ffe3;p=thirdparty%2Fhaproxy.git BUG/MINOR: converters: Store the sink in an arg pointer for debug() converter The debug() converter uses a string to reference the sink where to send debug events. During the configuration parsing, this string is converted to a sink object but it is still store as a string argument. It is a problem on deinit because string arguments are released. So the sink pointer will be released twice. To fix the bug, we keep a reference on the sink using an ARGT_PTR argument. This way, it will not be freed on the deinit. This patch depends on the commit e02fc4d0d ("MINOR: arg: Add an argument type to keep a reference on opaque data"). Both must be backported as far as 2.1. --- diff --git a/src/sample.c b/src/sample.c index 68b52acea1..2e221047b5 100644 --- a/src/sample.c +++ b/src/sample.c @@ -1452,7 +1452,7 @@ static int sample_conv_debug(const struct arg *arg_p, struct sample *smp, void * if (!buf) goto end; - sink = (struct sink *)arg_p[1].data.str.area; + sink = (struct sink *)arg_p[1].data.ptr; BUG_ON(!sink); pfx = arg_p[0].data.str.area; @@ -1514,8 +1514,8 @@ static int smp_check_debug(struct arg *args, struct sample_conv *conv, return 0; } - args[1].data.str.area = (char *)sink; - args[1].data.str.data = 0; // that's not a string anymore + args[1].type = ARGT_PTR; + args[1].data.ptr = sink; return 1; }