diff options
author | Jason Sams <jsams@google.com> | 2012-04-03 15:36:36 -0700 |
---|---|---|
committer | Jason Sams <jsams@google.com> | 2012-04-03 15:36:36 -0700 |
commit | e07694b24f7d12d72b084b6651356681ebd0efd6 (patch) | |
tree | e5cbb853579a105f5910c1c6640358e0cf69b5d9 /graphics/java/android/renderscript/BaseObj.java | |
parent | 991c8733c3b990b88edf5cf223aebe3d1c71b7f0 (diff) |
Validate context when using RS objects.
BUG=6035422
Change-Id: I8586be0085b36767289e1f634111c0ff076cec3c
Diffstat (limited to 'graphics/java/android/renderscript/BaseObj.java')
-rw-r--r-- | graphics/java/android/renderscript/BaseObj.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java index 2e55c48e6e18..f464f9bb1025 100644 --- a/graphics/java/android/renderscript/BaseObj.java +++ b/graphics/java/android/renderscript/BaseObj.java @@ -43,16 +43,22 @@ public class BaseObj { * Lookup the native object ID for this object. Primarily used by the * generated reflected code. * + * @param rs Context to verify against internal context for + * match. * * @return int */ - int getID() { + int getID(RenderScript rs) { + mRS.validate(); if (mDestroyed) { throw new RSInvalidStateException("using a destroyed object."); } if (mID == 0) { throw new RSRuntimeException("Internal error: Object id 0."); } + if ((rs != null) && (rs != mRS)) { + throw new RSInvalidStateException("using object with mismatched context."); + } return mID; } @@ -138,7 +144,7 @@ public class BaseObj { */ void updateFromNative() { mRS.validate(); - mName = mRS.nGetName(getID()); + mName = mRS.nGetName(getID(mRS)); } /** |