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:
parent
9dde51fcf3
commit
1094fcda7b
1 changed files with 2 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue