8253948: Memory leak in ImageFileReader
Reviewed-by: alanb
This commit is contained in:
parent
65cab55c1b
commit
81dae70f67
src/java.base/share/native/libjimage
@ -348,7 +348,8 @@ ImageFileReader* ImageFileReader::id_to_reader(u8 id) {
|
||||
}
|
||||
|
||||
// Constructor intializes to a closed state.
|
||||
ImageFileReader::ImageFileReader(const char* name, bool big_endian) {
|
||||
ImageFileReader::ImageFileReader(const char* name, bool big_endian) :
|
||||
_module_data(NULL) {
|
||||
// Copy the image file name.
|
||||
int len = (int) strlen(name) + 1;
|
||||
_name = new char[len];
|
||||
@ -369,6 +370,10 @@ ImageFileReader::~ImageFileReader() {
|
||||
delete[] _name;
|
||||
_name = NULL;
|
||||
}
|
||||
|
||||
if (_module_data != NULL) {
|
||||
delete _module_data;
|
||||
}
|
||||
}
|
||||
|
||||
// Open image file for read access.
|
||||
@ -419,9 +424,9 @@ bool ImageFileReader::open() {
|
||||
_string_bytes = _index_data + string_bytes_offset;
|
||||
|
||||
// Initialize the module data
|
||||
module_data = new ImageModuleData(this);
|
||||
_module_data = new ImageModuleData(this);
|
||||
// Successful open (if memory allocation succeeded).
|
||||
return module_data != NULL;
|
||||
return _module_data != NULL;
|
||||
}
|
||||
|
||||
// Close image file.
|
||||
@ -436,6 +441,11 @@ void ImageFileReader::close() {
|
||||
osSupport::close(_fd);
|
||||
_fd = -1;
|
||||
}
|
||||
|
||||
if (_module_data != NULL) {
|
||||
delete _module_data;
|
||||
_module_data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Read directly from the file.
|
||||
@ -568,5 +578,5 @@ void ImageFileReader::get_resource(ImageLocation& location, u1* uncompressed_dat
|
||||
|
||||
// Return the ImageModuleData for this image
|
||||
ImageModuleData * ImageFileReader::get_image_module_data() {
|
||||
return module_data;
|
||||
return _module_data;
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ private:
|
||||
u4* _offsets_table; // Location offset table
|
||||
u1* _location_bytes; // Location attributes
|
||||
u1* _string_bytes; // String table
|
||||
ImageModuleData *module_data; // The ImageModuleData for this image
|
||||
ImageModuleData *_module_data; // The ImageModuleData for this image
|
||||
|
||||
ImageFileReader(const char* name, bool big_endian);
|
||||
~ImageFileReader();
|
||||
|
Loading…
x
Reference in New Issue
Block a user