[Bug java/35979] New: JNI method NewStringUTF crashes when passed a NULL pointer

thomas dot g dot girard at free dot fr gcc-bugzilla@gcc.gnu.org
Sat Apr 19 12:07:00 GMT 2008


Hello,

when running java-gnome 4 unit tests, I've found out that gij NewStringUTF
implementation crashes when its argument is NULL. Indeed in natString.cc the
very first line of _Jv_NewStringUTF(const char *bytes) calls strlen(bytes),
without checking whether bytes is NULL or not. Hence the crash.

Sun's implementation does not crash: it returns NULL instead.

However it seems gij implementation is correct according to
http://java.sun.com/docs/books/jni/html/functions.html#65644:
  "Return Values. Returns a local reference to a string object, or NULL if the
string cannot be constructed. Returns NULL if and only if an invocation of this
function has thrown an exception."

Should gij implementation be changed to handle NULL? I've checked that the
crash should still occur on the trunk, r134466


-- 
           Summary: JNI method NewStringUTF crashes when passed a NULL
                    pointer
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thomas dot g dot girard at free dot fr
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35979



More information about the Gcc-bugs mailing list