8296347: Memory leak from ClassPathDirEntry::_dir

Co-authored-by: Justin King <jcking@google.com>
Reviewed-by: dholmes, ccheung
This commit is contained in:
Man Cao 2022-11-08 23:34:45 +00:00
parent 671f84bd86
commit 8146e1af82
2 changed files with 5 additions and 1 deletions

View file

@ -237,6 +237,10 @@ const char* ClassPathEntry::copy_path(const char* path) {
return copy; return copy;
} }
ClassPathDirEntry::~ClassPathDirEntry() {
FREE_C_HEAP_ARRAY(char, _dir);
}
ClassFileStream* ClassPathDirEntry::open_stream(JavaThread* current, const char* name) { ClassFileStream* ClassPathDirEntry::open_stream(JavaThread* current, const char* name) {
// construct full path name // construct full path name
assert((_dir != NULL) && (name != NULL), "sanity"); assert((_dir != NULL) && (name != NULL), "sanity");

View file

@ -80,7 +80,7 @@ class ClassPathDirEntry: public ClassPathEntry {
ClassPathDirEntry(const char* dir) { ClassPathDirEntry(const char* dir) {
_dir = copy_path(dir); _dir = copy_path(dir);
} }
virtual ~ClassPathDirEntry() {} virtual ~ClassPathDirEntry();
ClassFileStream* open_stream(JavaThread* current, const char* name); ClassFileStream* open_stream(JavaThread* current, const char* name);
}; };