From: Willy Tarreau Date: Tue, 18 Feb 2020 13:27:44 +0000 (+0100) Subject: BUG/MINOR: sample: exit regsub() in case of trash allocation error X-Git-Tag: v2.2-dev3~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23997daf4e23290c515014cedd04e3419029fb7b;p=thirdparty%2Fhaproxy.git BUG/MINOR: sample: exit regsub() in case of trash allocation error As reported in issue #507, since commiy 07e1e3c93e ("MINOR: sample: regsub now supports backreferences") we must not proceed in regsub() if we fali to allocate a trash (which in practice never happens). No backport needed. --- diff --git a/src/sample.c b/src/sample.c index 24d21100e0..d3568708df 100644 --- a/src/sample.c +++ b/src/sample.c @@ -2388,6 +2388,9 @@ static int sample_conv_regsub(const struct arg *arg_p, struct sample *smp, void break; output = alloc_trash_chunk(); + if (!output) + break; + output->data = exp_replace(output->area, output->size, start, arg_p[1].data.str.area, pmatch); /* replace the matching part */