Improved message 'mismatchSize' (#4167)
This commit is contained in:
parent
d118a56b42
commit
2d608890a5
|
@ -385,7 +385,7 @@ void CheckMemoryLeak::deallocuseError(const Token *tok, const std::string &varna
|
||||||
|
|
||||||
void CheckMemoryLeak::mismatchSizeError(const Token *tok, const std::string &sz) const
|
void CheckMemoryLeak::mismatchSizeError(const Token *tok, const std::string &sz) const
|
||||||
{
|
{
|
||||||
reportErr(tok, Severity::error, "mismatchSize", "The given size " + sz + " is mismatching");
|
reportErr(tok, Severity::error, "mismatchSize", "The allocated size " + sz + " is not a multiple of the underlying type's size.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckMemoryLeak::mismatchAllocDealloc(const std::list<const Token *> &callstack, const std::string &varname) const
|
void CheckMemoryLeak::mismatchAllocDealloc(const std::list<const Token *> &callstack, const std::string &varname) const
|
||||||
|
|
|
@ -3490,13 +3490,14 @@ private:
|
||||||
" int *p = malloc(3);\n"
|
" int *p = malloc(3);\n"
|
||||||
" free(p);\n"
|
" free(p);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) The given size 3 is mismatching\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (error) The allocated size 3 is not a multiple of the underlying type's size.\n", errout.str());
|
||||||
|
|
||||||
check("void foo()\n"
|
check("void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" int *p = g_malloc(3);\n"
|
" int *p = g_malloc(3);\n"
|
||||||
" g_free(p);\n"
|
" g_free(p);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
TODO_ASSERT_EQUALS("[test.cpp:3]: (error) The given size 3 is mismatching\n", "", errout.str());
|
TODO_ASSERT_EQUALS("[test.cpp:3]: (error) The allocated size 3 is not a multiple of the underlying type's size.\n", "", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue