Skip to content

Commit

Permalink
Merge pull request #51 from square/py/null_check_file
Browse files Browse the repository at this point in the history
Fix NPE on cleanup
  • Loading branch information
pyricau committed May 11, 2015
2 parents ba0de09 + 569a8a1 commit bf71228
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.squareup.leakcanary;

import android.util.Log;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
Expand Down Expand Up @@ -57,6 +58,7 @@
public final class HeapAnalyzer {

private static final String ANONYMOUS_CLASS_NAME_PATTERN = "^.+\\$\\d+$";
private static final String TAG = "HeapAnalyzer";

private final ExcludedRefs baseExcludedRefs;
private final ExcludedRefs excludedRefs;
Expand Down Expand Up @@ -337,8 +339,12 @@ private void cleanup(File heapDumpFile, ISnapshot snapshot) {
.equals(heapDumpFileName);
}
});
for (File file : toRemove) {
file.delete();
if (toRemove != null) {
for (File file : toRemove) {
file.delete();
}
} else {
Log.d(TAG, "Could not find HAHA files to cleanup.");
}
}

Expand Down

0 comments on commit bf71228

Please sign in to comment.