Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit c2453cf

Browse files
authored
Merge pull request thaliproject#125 from zeroleak/fix-leak-scanner
Fix possible memory leak on OsData
2 parents f49f2d2 + 9e294d1 commit c2453cf

File tree

1 file changed

+3
-1
lines changed
  • universal/src/main/java/com/msopentech/thali/toronionproxy

1 file changed

+3
-1
lines changed

universal/src/main/java/com/msopentech/thali/toronionproxy/OsData.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ protected static OsType actualGetOsType() {
6868
protected static OsType getLinuxType() {
6969
String [] cmd = { "uname", "-m" };
7070
Process unameProcess = null;
71+
Scanner scanner = null;
7172
try {
7273
String unameOutput;
7374
unameProcess = Runtime.getRuntime().exec(cmd);
7475

75-
Scanner scanner = new Scanner(unameProcess.getInputStream());
76+
scanner = new Scanner(unameProcess.getInputStream());
7677
if (scanner.hasNextLine()) {
7778
unameOutput = scanner.nextLine();
7879
} else {
@@ -97,6 +98,7 @@ protected static OsType getLinuxType() {
9798
throw new RuntimeException("Uname failure", e);
9899
} finally {
99100
if (unameProcess != null) {
101+
scanner.close();
100102
unameProcess.destroy();
101103
}
102104
}

0 commit comments

Comments
 (0)