This is a patch to fix a very minor bug. But at least it helps in making
reg tests with the address sanitizer passes.
Fred.
>From e75d5fee861d8f3da68238c337512c71d090ac8c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= <flecai...@haproxy.com>
Date: Wed, 11 Jul 2018 10:31:29 +0200
Subject: [PATCH] BUG/MINOR: thread: log: Log buffers allocated twice.
This issue has been reported by Ilya Shipitsin when running
reg tests with asan (address sanitizer). asan detects
that the logging buffers have been allocated twice by the main
thread, the first calling directly init_log_buffer(), the second
calling init_log_buffers_per_thread() for all the threads, main
thread included.
Furthermore this patch fixes a typo between pointer variable names
when checking their allocation results.
Thanks to Ilya Shipitsin for having reported this issue.
This patch must be backported to 1.8.
---
src/log.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/log.c b/src/log.c
index b2d4367..7b33f95 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1539,12 +1539,17 @@ static void deinit_log_buffers_per_thread()
/* Initialize log buffers used for syslog messages */
int init_log_buffers()
{
- logheader = my_realloc2(logheader, global.max_syslog_len + 1);
- logheader_rfc5424 = my_realloc2(logheader_rfc5424, global.max_syslog_len + 1);
- logline = my_realloc2(logline, global.max_syslog_len + 1);
- logline_rfc5424 = my_realloc2(logline_rfc5424, global.max_syslog_len + 1);
- if (!logheader || !logline_rfc5424 || !logline || !logline_rfc5424)
+ if (!logheader)
+ logheader = my_realloc2(logheader, global.max_syslog_len + 1);
+ if (!logheader_rfc5424)
+ logheader_rfc5424 = my_realloc2(logheader_rfc5424, global.max_syslog_len + 1);
+ if (!logline)
+ logline = my_realloc2(logline, global.max_syslog_len + 1);
+ if (!logline_rfc5424)
+ logline_rfc5424 = my_realloc2(logline_rfc5424, global.max_syslog_len + 1);
+ if (!logheader || !logheader_rfc5424 || !logline || !logline_rfc5424)
return 0;
+
return 1;
}
--
2.1.4