Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimeon Andreev2019-12-02 14:21:24 +0000
committerSimeon Andreev2019-12-02 14:21:24 +0000
commit9d897fcc04f39fe62ca1e5935d341e0a4b60f30d (patch)
tree462341837fea1e744c7e855fb76cba290f09640c
parent51d8fbf6663c656c45dba88ad1eef68eb68ef3a1 (diff)
downloadorg.eclipse.cdt-9d897fcc04f39fe62ca1e5935d341e0a4b60f30d.tar.gz
org.eclipse.cdt-9d897fcc04f39fe62ca1e5935d341e0a4b60f30d.tar.xz
org.eclipse.cdt-9d897fcc04f39fe62ca1e5935d341e0a4b60f30d.zip
Bug 553667 - Resource leak in ElfParser
This change fixes a file descriptor leak in ElfParser.hasInterpProgramHeader(). An Elf object is created without calling its Elf.dispose(). This results in a created RandomAccessFile object, without a respective RandomAccessFile.close() call. Change-Id: I6d2a0911857eb6fcb388b352801c2259ae19171c Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfParser.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfParser.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfParser.java
index 413295e5b34..0bcdb51465f 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfParser.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/parser/ElfParser.java
@@ -190,10 +190,19 @@ public class ElfParser extends AbstractCExtension implements IBinaryParser {
try {
/* No PHdr.PT_INTERP found in the hints meaning we need to read the file itself */
- return Arrays.stream(new Elf(path.toOSString()).getPHdrs()).anyMatch(phdr -> phdr.p_type == PHdr.PT_INTERP);
+ return Arrays.stream(getPHdrs(path)).anyMatch(phdr -> phdr.p_type == PHdr.PT_INTERP);
} catch (IOException e) {
CCorePlugin.log(e);
}
return false;
}
+
+ private static PHdr[] getPHdrs(IPath path) throws IOException {
+ Elf elf = new Elf(path.toOSString());
+ try {
+ return elf.getPHdrs();
+ } finally {
+ elf.dispose();
+ }
+ }
}

Back to the top