From 18668a52b9115239547b4db81a227c38ac75ca79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 17 Mar 2019 10:55:15 +0100 Subject: [PATCH] Library: Added buffer-size attribute for --- cfg/cppcheck-cfg.rng | 9 +++++++++ cfg/std.cfg | 2 +- lib/library.cpp | 7 +++++++ lib/library.h | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cfg/cppcheck-cfg.rng b/cfg/cppcheck-cfg.rng index 2d638920b..1339fbba7 100644 --- a/cfg/cppcheck-cfg.rng +++ b/cfg/cppcheck-cfg.rng @@ -32,6 +32,9 @@ + + + @@ -458,6 +461,12 @@ + + + arg-value:[1-3] + + + resize diff --git a/cfg/std.cfg b/cfg/std.cfg index 749d40c3d..f57921694 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -7320,7 +7320,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun - malloc + malloc calloc aligned_alloc valloc diff --git a/lib/library.cpp b/lib/library.cpp index 4be26049e..56512aae6 100644 --- a/lib/library.cpp +++ b/lib/library.cpp @@ -200,6 +200,13 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc) temp.arg = atoi(arg); else temp.arg = -1; + + const char *bufferSize = memorynode->Attribute("buffer-size"); + if (bufferSize && std::strncmp(bufferSize, "arg-value:", 10) == 0) + temp.bufferSizeArgValue = bufferSize[10] - '0'; + else + temp.bufferSizeArgValue = -1; + mAlloc[memorynode->GetText()] = temp; } else if (memorynodename == "dealloc") { AllocFunc temp; diff --git a/lib/library.h b/lib/library.h index cd25eb254..508f970b9 100644 --- a/lib/library.h +++ b/lib/library.h @@ -73,6 +73,7 @@ public: struct AllocFunc { int groupId; int arg; + int bufferSizeArgValue; }; /** get allocation info for function */