Fix memory overflow. Need to allocate one extra byte for the null

termination for the string


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10248 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Joseph Wang 2008-02-12 06:53:35 +00:00
commit 1094fcda7b

View file

@ -23,7 +23,8 @@ getObject(int i, double d)
obj->i = i;
obj->d = d;
obj->str = (char *)malloc(strlen(test_string));
/* allocate one extra byte for the null */
obj->str = (char *)malloc(strlen(test_string) + 1);
strcpy(obj->str, test_string);
return(obj);