diff options
author | schnetter <schnetter@eec4d7dc-71c2-46d6-addf-10296150bf52> | 2008-02-27 05:20:47 +0000 |
---|---|---|
committer | schnetter <schnetter@eec4d7dc-71c2-46d6-addf-10296150bf52> | 2008-02-27 05:20:47 +0000 |
commit | 46a52f381cb45353b9ae66bf06d2145c9d875f4a (patch) | |
tree | 9d2b2b201f63aa8fd961a19c0559aff1b0922edc | |
parent | 79ab42a17b17e72fdb0adc0113a569cd2a48e862 (diff) |
Correct malloc error and memory leak when the tag "whiskycartoon" is
used
git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Cartoon2D/trunk@103 eec4d7dc-71c2-46d6-addf-10296150bf52
-rw-r--r-- | src/ApplyCartoon.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/ApplyCartoon.c b/src/ApplyCartoon.c index f0e48ed..89cfd1d 100644 --- a/src/ApplyCartoon.c +++ b/src/ApplyCartoon.c @@ -94,7 +94,7 @@ void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS) char prolongtype[PROLONG_BUFF_SIZE]; int prolongmethod; - int tableindex, len; + int whiskycartoon, len; @@ -160,13 +160,30 @@ void Cartoon_ApplyBoundaries(CCTK_ARGUMENTS) len = Util_TableGetString(group_tags_table,0,NULL,"whiskycartoon"); - char* value = malloc (len + 1); - Util_TableGetString (group_tags_table, len + 1, value, "whiskycartoon"); - + whiskycartoon = 1; /* default is yes */ + if (len >= 0) + { + char* value = malloc (len + 1); + Util_TableGetString (group_tags_table, len + 1, value, "whiskycartoon"); + if (CCTK_Equals(value, "yes")) + { + whiskycartoon = 1; + } + else if (CCTK_Equals(value, "no")) + { + whiskycartoon = 0; + } + else + { + CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Tags table entry \"whiskycartoon\" for variable group %s should be either \"yes\" or \"no\", but is \"%s\"", + CCTK_GroupName(gi), value); + } + free (value); + } - if (len <= 0 || CCTK_Equals(value, "yes")) + if (whiskycartoon) { - free(value); /*###################################################################*/ |