8140649: imageFile should use delete[] with new[]
authorasmotrak
Mon, 09 Nov 2015 13:58:10 +0300
changeset 33645 1af4c728e3e8
parent 33644 c60dc808ff5a
child 33646 aeed9f07a50c
8140649: imageFile should use delete[] with new[] Reviewed-by: jlaskey
jdk/src/java.base/share/native/libjimage/imageFile.cpp
--- a/jdk/src/java.base/share/native/libjimage/imageFile.cpp	Mon Nov 09 09:23:49 2015 +0100
+++ b/jdk/src/java.base/share/native/libjimage/imageFile.cpp	Mon Nov 09 13:58:10 2015 +0300
@@ -118,7 +118,7 @@
     // Deflate the attribute stream into an array of attributes.
     u1 byte;
     // Repeat until end header is found.
-    while ((byte = *data)) {
+    while ((data != NULL) && (byte = *data)) {
         // Extract kind from header byte.
         u1 kind = attribute_kind(byte);
         assert(kind < ATTRIBUTE_COUNT && "invalid image location attribute");
@@ -191,7 +191,7 @@
 // Release module data resource.
 ImageModuleData::~ImageModuleData() {
     if (_data) {
-        delete _data;
+        delete[] _data;
     }
 }
 
@@ -274,7 +274,7 @@
 }
 
 ImageFileReaderTable::~ImageFileReaderTable() {
-    delete _table;
+    delete[] _table;
 }
 
 // Add a new image entry to the table.
@@ -414,7 +414,7 @@
     close();
     // Free up name.
     if (_name) {
-        delete _name;
+        delete[] _name;
         _name = NULL;
     }
 }
@@ -668,7 +668,7 @@
                         &strings);
         // If not memory mapped then release temporary buffer.
         if (!MemoryMapImage) {
-                delete compressed_data;
+                delete[] compressed_data;
         }
     } else {
         // Read bytes from offset beyond the image index.