From 9afae310b019aa497afb94833afc9a936bc38a1f Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 12 Aug 2016 14:39:50 +0200 Subject: utils: Don't return directly from SNPRINTF_BUFFER_SIZE Apart from being a bad idea in general, the return statement contained in that macro in some cases leads to returning from functions without properly cleaning up, thereby causing memory leaks. Instead, just sanitize the value in 'ret' to not harm further calls of snprintf() (as 'len' will eventually just become zero). Cc: Arturo Borrero Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- include/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/utils.h b/include/utils.h index 21694b6..924df32 100644 --- a/include/utils.h +++ b/include/utils.h @@ -54,7 +54,7 @@ void __nftnl_assert_attr_exists(uint16_t attr, uint16_t attr_max, #define SNPRINTF_BUFFER_SIZE(ret, size, len, offset) \ if (ret < 0) \ - return ret; \ + ret = 0; \ offset += ret; \ if (ret > len) \ ret = len; \ -- cgit v1.2.3