From b6d2eff8b1ad4ceed1f8a97f19e43aff5452898f Mon Sep 17 00:00:00 2001 From: Nathan Harold Date: Thu, 6 Jul 2017 16:57:51 -0700 Subject: [PATCH] Check ManagedResource is NonNull before Checking Owner If an invalid Resource Id is provided to the Managed Resource Array getter, we should just return null rather than asserting the owner of the resource. Bug: none Test: tbd Change-Id: I407a96e4e82e9d6bf68e89380a88d3851efe4305 --- services/core/java/com/android/server/IpSecService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/IpSecService.java b/services/core/java/com/android/server/IpSecService.java index ec275cc6f77d7..58f1c8d0dd603 100644 --- a/services/core/java/com/android/server/IpSecService.java +++ b/services/core/java/com/android/server/IpSecService.java @@ -206,7 +206,11 @@ public class IpSecService extends IIpSecService.Stub { T get(int key) { T val = mArray.get(key); - val.checkOwnerOrSystemAndThrow(); + // The value should never be null unless the resource doesn't exist + // (since we do not allow null resources to be added). + if (val != null) { + val.checkOwnerOrSystemAndThrow(); + } return val; }