diff --git a/cfg/gnu.cfg b/cfg/gnu.cfg
index 688145e2f..d22bdbef8 100644
--- a/cfg/gnu.cfg
+++ b/cfg/gnu.cfg
@@ -14,6 +14,7 @@
xstrdup
xrealloc
free
+ xfree
@@ -66,6 +67,13 @@
+
+
+
+
+
+
+
diff --git a/test/cfg/gnu.c b/test/cfg/gnu.c
index db3531e3a..e0daf2f98 100644
--- a/test/cfg/gnu.c
+++ b/test/cfg/gnu.c
@@ -19,6 +19,7 @@
extern void *xcalloc(size_t nmemb, size_t size);
extern void *xmalloc(size_t size);
extern void *xrealloc(void *block, size_t newsize);
+extern void xfree(void *ptr);
void resourceLeak_mkostemps(char *template, int suffixlen, int flags)
{
@@ -76,8 +77,19 @@ int no_resourceLeak_mkostemp_02(char *template, int flags)
void valid_code(int argInt1)
{
+ char *p;
+
if (__builtin_expect(argInt1, 0)) {}
if (__builtin_expect_with_probability(argInt1 + 1, 2, 0.5)) {}
+
+ p = (char *)malloc(10);
+ free(p);
+ p = (char *)malloc(5);
+ xfree(p);
+ p = (char *)xmalloc(10);
+ free(p);
+ p = (char *)xmalloc(5);
+ xfree(p);
}
void ignoreleak(void)
@@ -98,6 +110,13 @@ void memleak_asprintf(char **ptr, const char *fmt, const int arg)
}
}
+void memleak_xmalloc()
+{
+ char *p = (char*)xmalloc(10);
+ p[9] = 0;
+ // cppcheck-suppress memleak
+}
+
void uninitvar__builtin_memset(void)
{
void *s;