I noticed that the STRING_OUT typemap could possibly reference uninitialized memory:
char **arg1 = (char **) 0 ;
char *temp1 ; // here's the uninitialized memory
...
arg1 = &temp1; // we point at the uninitialized memory
}
result = (int)foo(arg1); // foo() takes a code path that does not set up *arg1, like returning immediately
jresult = (jint)result;
{
jstring jnewstring = NULL;
if (arg1) {
jnewstring = (*jenv)->NewStringUTF(jenv, *arg1); // construct a new string with the uninitialized memory
}
...
The patch simply initializes the uninitialized memory. I'm assuming that NewStringUTF has some behavior with NULL besides a segfault.
Input file showing the bug.
Thanks. Added for swig-2.0.7.