From 7c09b0cfe0e8ff4cecfc37b4156cdf4b9ed6dfd0 Mon Sep 17 00:00:00 2001 From: versat Date: Thu, 21 Mar 2019 10:44:18 +0100 Subject: [PATCH] gnu.cfg: Add "buffer-size" attribute and tests for xcalloc(). --- cfg/gnu.cfg | 2 +- test/cfg/gnu.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cfg/gnu.cfg b/cfg/gnu.cfg index 6af4d572b..1499b150e 100644 --- a/cfg/gnu.cfg +++ b/cfg/gnu.cfg @@ -10,7 +10,7 @@ xmalloc - xcalloc + xcalloc free diff --git a/test/cfg/gnu.c b/test/cfg/gnu.c index d6ef90701..821f4ebc3 100644 --- a/test/cfg/gnu.c +++ b/test/cfg/gnu.c @@ -63,6 +63,14 @@ void bufferAccessOutOfBounds() sethostname(buf, 2); // cppcheck-suppress bufferAccessOutOfBounds sethostname(buf, 4); + + // Declaration necessary because there is no specific / portable header containing xcalloc. + extern void *xcalloc(size_t nmemb, size_t size); + char * pAlloc1 = xcalloc(2, 4); + memset(pAlloc1, 0, 8); + // cppcheck-suppress bufferAccessOutOfBounds + memset(pAlloc1, 0, 9); + free(pAlloc1); } void leakReturnValNotUsed()