Skip to content

Commit

Permalink
PackageUtil: Fix NPE in getPackageInfo method
Browse files Browse the repository at this point in the history
Added a null check before accessing the file array length to prevent a crash caused by a NullPointerException in cases where the directory is not valid or is inaccessible

Issue: calyxos#2834
Change-Id: I5906ff6b415a766c9cad66220d8ae9ed2290bdb8
  • Loading branch information
Uldiniad authored and NurKeinNeid committed Dec 1, 2024
1 parent 7203fcc commit 912ef06
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public static PackageInfo getPackageInfo(Context context, File sourceFile, int f
String filePath = sourceFile.getAbsolutePath();
if (filePath.endsWith(SPLIT_BASE_APK_END_WITH)) {
File dir = sourceFile.getParentFile();
if (dir.listFiles().length > 1) {
File[] files = dir.listFiles();
if (files != null && files.length > 1) {
// split apks, use file directory to get archive info
filePath = dir.getPath();
}
Expand Down

0 comments on commit 912ef06

Please sign in to comment.