From e9768f22d19276332ec16db585af6d1de0503931 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 7 Aug 2020 14:00:23 +0200 Subject: [PATCH] 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. (cherry picked from commit b45bf8eb70789264b9fd38fd6c1bc1c1c723ffe3) Signed-off-by: Willy Tarreau (cherry picked from commit c89077713915f605eb5d716545f182c8d0bf5581) Signed-off-by: Willy Tarreau --- src/sample.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sample.c b/src/sample.c index 6de5a9d..fb65982 100644 --- a/src/sample.c +++ b/src/sample.c @@ -1451,7 +1451,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; @@ -1513,8 +1513,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; } -- 1.7.10.4