PackageManagerService: Fix a null pointer exception in addForInitLI

The original code can potentially access a null pointer in
"pkgSetting" variable while preparing for an exception to throw.
This CL adds a check before using its value.

Bug: 189106370
Test: Build successful. No regression in app installation.
Change-Id: I6390a5d20409ac8641e91bffa6a85fefc50c68a6
(cherry picked from commit efda5d48a3343830a58b49ce363dc108be916b47)
(cherry picked from commit ced771333beb7e35c89715a20081f261b8521819)
This commit is contained in:
Cherie Cheung
2021-06-23 16:19:52 +09:00
parent e166cae76e
commit ca051dd9d9

View File

@@ -12172,8 +12172,8 @@ public class PackageManagerService extends IPackageManager.Stub
parsedPackage.hideAsFinal();
throw new PackageManagerException(Log.WARN, "Package " + parsedPackage.getPackageName()
+ " at " + parsedPackage.getPath() + " ignored: updated version "
+ pkgSetting.versionCode + " better than this "
+ parsedPackage.getLongVersionCode());
+ (pkgAlreadyExists ? String.valueOf(pkgSetting.versionCode) : "unknown")
+ " better than this " + parsedPackage.getLongVersionCode());
}
// Verify certificates against what was last scanned. Force re-collecting certificate in two