Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8027857

(prefs) Null check missing in java_java_util_prefs_filesystempreferences_lockfile

XMLWordPrintable

      Our source licensee has hit a crash in a particular scenario when the
      memory limit is reached and they are trying to create an array using
      NewIntArray(). In this case NewIntArray() returns NULL. As we don’t have the
      NULL check for javaResult, this leads to crash later.

      This issue is seen with JDK 5.0 , 6.0 & 7.0 too . From the suggested
      change below, our understanding is that this is platform independent. The
      following are the suggested changes:

      --- FileSystemPreferences.c (revision 6511)
      +++ FileSystemPreferences.c (working copy)
      @@ -136,6 +136,10 @@
           }
           JNU_ReleaseStringPlatformChars(env, java_fname, fname);
           javaResult = (*env)->NewIntArray(env,2);
      + if (javaResult == NULL) {
      + JNU_ThrowOutOfMemoryError(env, "Out of Memory");
      + return -1;
      + }
           (*env)->SetIntArrayRegion(env, javaResult, 0, 2, result);
           return javaResult;
      }

            dmeetry Dmeetry Degrave (Inactive)
            asaha Abhijit Saha
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: