< prev index next >

src/java.base/windows/native/libjava/io_util_md.c

Print this page
rev 50965 : imported patch 8207060-Memory-leak-when-malloc-fails-within-WITH_UNICODE_STRING-block

@@ -163,13 +163,10 @@
                      pathbuf = prefixAbpath(ps, pathlen, pathlen);
                  } else {
                      pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
                      if (pathbuf != 0) {
                          wcscpy(pathbuf, ps);
-                     } else {
-                         JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
-                         return NULL;
                      }
                  }
             } else {
                 /* If the path came in as a relative path, need to verify if
                    its absolute form is bigger than max_path or not, if yes

@@ -189,13 +186,10 @@
                     pathbuf = prefixAbpath(ps, pathlen, dirlen + pathlen);
                 } else {
                     pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
                     if (pathbuf != 0) {
                         wcscpy(pathbuf, ps);
-                    } else {
-                        JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
-                        return NULL;
                     }
                 }
             }
         }
     } END_UNICODE_STRING(env, ps);

@@ -208,19 +202,15 @@
             return NULL;
         } else {
             pathbuf = (WCHAR*)malloc(sizeof(WCHAR));
             if (pathbuf != NULL) {
                 pathbuf[0] = L'\0';
-            } else {
-                JNU_ThrowOutOfMemoryError(env, 0);
-                return NULL;
             }
         }
     }
     if (pathbuf == 0) {
-        JNU_ThrowOutOfMemoryError(env, 0);
-        return NULL;
+        JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
     }
     return pathbuf;
 }
 
 JNIEXPORT FD JNICALL
< prev index next >