From 49d3e07b59819c5f999369feb04543154a752817 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 11 Nov 2021 20:25:10 +0100 Subject: [PATCH] Add test case for #10137 (#3558) --- test/testbufferoverrun.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 85999a34c..d8a65410c 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -4737,6 +4737,19 @@ private: " return foo(1, &single_value);\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("void f(const char* app, size_t applen) {\n" // #10137 + " char* tmp_de = NULL;\n" + " char** str = &tmp_de;\n" + " char* tmp = (char*)realloc(*str, applen + 1);\n" + " if (tmp) {\n" + " *str = tmp;\n" + " memcpy(*str, app, applen);\n" + " (*str)[applen] = '\\0';\n" + " }\n" + " free(*str);\n" + "}\n", "test.c"); + ASSERT_EQUALS("", errout.str()); } };