Fixed #6311: Add support for GNU get_current_dir_name().
This commit is contained in:
parent
6f000fb16b
commit
37c89a6b70
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<def format="1">
|
||||||
|
<memory>
|
||||||
|
<dealloc>free</dealloc>
|
||||||
|
<alloc init="true">get_current_dir_name</alloc>
|
||||||
|
</memory>
|
||||||
|
</def>
|
|
@ -369,6 +369,8 @@ private:
|
||||||
// test that the cfg files are configured correctly
|
// test that the cfg files are configured correctly
|
||||||
TEST_CASE(posixcfg);
|
TEST_CASE(posixcfg);
|
||||||
TEST_CASE(posixcfg_mmap);
|
TEST_CASE(posixcfg_mmap);
|
||||||
|
|
||||||
|
TEST_CASE(gnucfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getcode(const char code[], const char varname[], bool classfunc=false) {
|
std::string getcode(const char code[], const char varname[], bool classfunc=false) {
|
||||||
|
@ -4272,6 +4274,21 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: p\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: p\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gnucfg() {
|
||||||
|
Settings settings;
|
||||||
|
settings.standards.posix = true;
|
||||||
|
LOAD_LIB_2(settings.library, "gnu.cfg");
|
||||||
|
const char code[] = "void leak() {\n"
|
||||||
|
" char * p = get_current_dir_name();\n" // memory leak
|
||||||
|
"}\n"
|
||||||
|
"void noLeak() {\n"
|
||||||
|
" char * p = get_current_dir_name;\n"
|
||||||
|
" free(p)\n;"
|
||||||
|
"}";
|
||||||
|
check(code, &settings);
|
||||||
|
ASSERT_EQUALS("[test.cpp:3]: (error) Memory leak: p\n", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
// Test that posix.cfg is configured correctly
|
// Test that posix.cfg is configured correctly
|
||||||
void posixcfg() {
|
void posixcfg() {
|
||||||
Settings settings;
|
Settings settings;
|
||||||
|
|
Loading…
Reference in New Issue