diff options
author | Yang Ni <yangni@google.com> | 2015-04-30 16:13:54 -0700 |
---|---|---|
committer | Yang Ni <yangni@google.com> | 2015-05-04 15:09:29 -0700 |
commit | 17c2d7a3e1fac8d8876262255eb24f2f81c8fbac (patch) | |
tree | 107ce3e7f6d8ff7651dbeca77f49867c9e0d5522 /rs/java/android | |
parent | 0425de31cf9a2ad8e5883c64d27dc2ee90d0377c (diff) | |
download | frameworks_base-17c2d7a3e1fac8d8876262255eb24f2f81c8fbac.zip frameworks_base-17c2d7a3e1fac8d8876262255eb24f2f81c8fbac.tar.gz frameworks_base-17c2d7a3e1fac8d8876262255eb24f2f81c8fbac.tar.bz2 |
Sanity checks in JNI code for closure creation
b/20728113
In case the requested size for memory allocation overflows, or memory
allocation fails.
Change-Id: I8dac132dd4d0210938660ffbb82cbe44000d2a90
(cherry picked from commit 4e90b9b57cc96964a9d5c1845172a72cb51feafb)
Diffstat (limited to 'rs/java/android')
-rw-r--r-- | rs/java/android/renderscript/RenderScript.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index e7f210b..4f10699 100644 --- a/rs/java/android/renderscript/RenderScript.java +++ b/rs/java/android/renderscript/RenderScript.java @@ -302,8 +302,12 @@ public class RenderScript { long[] fieldIDs, long[] values, int[] sizes, long[] depClosures, long[] depFieldIDs) { validate(); - return rsnClosureCreate(mContext, kernelID, returnValue, fieldIDs, values, + long c = rsnClosureCreate(mContext, kernelID, returnValue, fieldIDs, values, sizes, depClosures, depFieldIDs); + if (c == 0) { + throw new RSRuntimeException("Failed creating closure."); + } + return c; } native long rsnInvokeClosureCreate(long con, long invokeID, byte[] params, @@ -311,8 +315,12 @@ public class RenderScript { synchronized long nInvokeClosureCreate(long invokeID, byte[] params, long[] fieldIDs, long[] values, int[] sizes) { validate(); - return rsnInvokeClosureCreate(mContext, invokeID, params, fieldIDs, + long c = rsnInvokeClosureCreate(mContext, invokeID, params, fieldIDs, values, sizes); + if (c == 0) { + throw new RSRuntimeException("Failed creating closure."); + } + return c; } native void rsnClosureSetArg(long con, long closureID, int index, @@ -337,7 +345,11 @@ public class RenderScript { synchronized long nScriptGroup2Create(String name, String cachePath, long[] closures) { validate(); - return rsnScriptGroup2Create(mContext, name, cachePath, closures); + long g = rsnScriptGroup2Create(mContext, name, cachePath, closures); + if (g == 0) { + throw new RSRuntimeException("Failed creating script group."); + } + return g; } native void rsnScriptGroup2Execute(long con, long groupID); |