From: Christopher Faulet Date: Fri, 5 Feb 2021 09:29:29 +0000 (+0100) Subject: CLEANUP: http-htx: Set buffer area to NULL instead of malloc(0) X-Git-Tag: v2.4-dev7~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1cdc02868771ced6f3f8b5f8dc4725ceae68f842;p=thirdparty%2Fhaproxy.git CLEANUP: http-htx: Set buffer area to NULL instead of malloc(0) During error files conversion to HTX message, in http_str_to_htx(), if a file is empty, the corresponding buffer's area is initialized with a malloc(0) and its size is set to 0. There is no problem here. The behaviour is totally defined. But it is not really intuitive. Instead, we can simply set the area to NULL. This patch should fix the issue #1022. --- diff --git a/src/http_htx.c b/src/http_htx.c index a42e296ee2..bb3d8d0f09 100644 --- a/src/http_htx.c +++ b/src/http_htx.c @@ -904,7 +904,7 @@ int http_str_to_htx(struct buffer *buf, struct ist raw, char **errmsg) b_reset(buf); if (!raw.len) { buf->size = 0; - buf->area = malloc(raw.len); + buf->area = NULL; return 1; }