8146249: libjimage should use delete[] with new[]
authorasmotrak
Tue, 02 Feb 2016 12:50:03 -0800
changeset 35698 409a5492076d
parent 35697 7fa18fc6e339
child 35699 2a610264e6fc
8146249: libjimage should use delete[] with new[] Reviewed-by: jlaskey
jdk/src/java.base/share/native/libjimage/ImageNativeSubstrate.cpp
jdk/src/java.base/share/native/libjimage/imageDecompressor.cpp
--- a/jdk/src/java.base/share/native/libjimage/ImageNativeSubstrate.cpp	Tue Feb 02 11:50:55 2016 -0800
+++ b/jdk/src/java.base/share/native/libjimage/ImageNativeSubstrate.cpp	Tue Feb 02 12:50:03 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -210,7 +210,7 @@
     // Locate resource location data.
     ImageLocation location;
     bool found = reader->find_location(path, location);
-    delete path;
+    delete[] path;
     // Resource not found.
     if (!found) return NULL;
     // Expand stream into array.
--- a/jdk/src/java.base/share/native/libjimage/imageDecompressor.cpp	Tue Feb 02 11:50:55 2016 -0800
+++ b/jdk/src/java.base/share/native/libjimage/imageDecompressor.cpp	Tue Feb 02 12:50:03 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -86,7 +86,7 @@
 }
 
 void ImageDecompressor::image_decompressor_close() {
-    delete _decompressors;
+    delete[] _decompressors;
 }
 
 /*
@@ -135,13 +135,13 @@
             decompressor->decompress_resource(compressed_resource, decompressed_resource,
                 &_header, strings);
             if (compressed_resource_base != compressed) {
-                delete compressed_resource_base;
+                delete[] compressed_resource_base;
             }
             compressed_resource = decompressed_resource;
         }
     } while (has_header);
     memcpy(uncompressed, decompressed_resource, uncompressed_size);
-    delete decompressed_resource;
+    delete[] decompressed_resource;
 }
 
 // Zip decompressor
@@ -241,7 +241,7 @@
                                 *fullpkg = '/';
                                 memcpy(uncompressed_resource, pkg_base, len);
                                 uncompressed_resource += len;
-                                delete pkg_base;
+                                delete[] pkg_base;
                                 desc_length += len;
                             } else { // Empty package
                                 // Nothing to do.