Skip to content

Commit 00ee3ff

Browse files
committed
8283469: Don't use memset to initialize members in FileMapInfo and fix memory leak
Reviewed-by: mdoerr Backport-of: d6fa8b004bcd0a2fc1015055d0177428889b4c31
1 parent 364ed1d commit 00ee3ff

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/hotspot/share/memory/filemap.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,23 @@ template <int N> static void get_header_version(char (&header_version) [N]) {
162162
assert(header_version[JVM_IDENT_MAX-1] == 0, "must be");
163163
}
164164

165-
FileMapInfo::FileMapInfo() {
165+
FileMapInfo::FileMapInfo() :
166+
_file_open(false), _fd(-1), _file_offset(0), _full_path(NULL), _paths_misc_info(NULL) {
166167
assert(_current_info == NULL, "must be singleton"); // not thread safe
167168
_current_info = this;
168-
memset((void*)this, 0, sizeof(FileMapInfo));
169-
_file_offset = 0;
170-
_file_open = false;
171169
_header = (FileMapHeader*)os::malloc(sizeof(FileMapHeader), mtInternal);
172170
_header->_version = INVALID_CDS_ARCHIVE_VERSION;
173171
_header->_has_platform_or_app_classes = true;
174172
}
175173

176174
FileMapInfo::~FileMapInfo() {
175+
assert(_header != NULL, "Sanity");
176+
os::free(_header);
177+
178+
if (_file_open) {
179+
::close(_fd);
180+
}
181+
177182
assert(_current_info == this, "must be singleton"); // not thread safe
178183
_current_info = NULL;
179184
}

0 commit comments

Comments
 (0)