#313 Java STRING_ARRAY output typemap could dereference a NULL

general (37)
Leo Davis

I was examining the JNI output from SWIG and noticed that I could get a NULL pointer dereference if I was wrapping char** foo(void) with
a STRING_ARRAY and foo() returned NULL:

result = (char **)foo();
int i;
int len=0;
jstring temp_string;
const jclass clazz = (*jenv)->FindClass(jenv, "java/lang/String");

while (result[len]) len++; // dereference NULL here

The patch I attached simply wraps all the %typemap(out) code in an if test.


  • Leo Davis

    Leo Davis - 2012-04-27

    patch based on SWIG 2.0.5 which should fix the problem

  • Leo Davis

    Leo Davis - 2012-04-27

    Simple input file demonstrating the problem.

  • William Fulton

    William Fulton - 2012-04-28

    Thanks, applied for swig-2.0.6 along with a further fix for the 'in' typemap to handle null pointers.

  • William Fulton

    William Fulton - 2012-04-28
    • assigned_to: nobody --> wsfulton
    • status: open --> closed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks