From f1cabd08a27376baf9b74879ebd660385dfde001 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 6 Apr 2008 21:21:29 +0000 Subject: [PATCH] fix stack overflow when using typemap warning suppression, eg %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10359 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/error.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Swig/error.c b/Source/Swig/error.c index f7c7bdaa4..1eaba1f17 100644 --- a/Source/Swig/error.c +++ b/Source/Swig/error.c @@ -190,19 +190,22 @@ void Swig_warnfilter(const String_or_char *wlist, int add) { c = strtok(c, ", "); while (c) { if (isdigit((int) *c) || (*c == '+') || (*c == '-')) { + /* Even if c is a digit, the rest of the string might not be, eg in the case of typemap + * warnings (a bit odd really), eg: %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) */ if (add) { Insert(filter, 0, c); if (isdigit((int) *c)) { Insert(filter, 0, "-"); } } else { - char temp[32]; + char *temp = (char *)malloc(sizeof(char)*strlen(c) + 2); if (isdigit((int) *c)) { sprintf(temp, "-%s", c); } else { strcpy(temp, c); } Replace(filter, temp, "", DOH_REPLACE_FIRST); + free(temp); } } c = strtok(NULL, ", ");