Better handle error log and nullptr reference.

Bug: 27367378

Change-Id: Ide29c702d7a70dfe087ddc600d3fd17279223196
diff --git a/cpu_ref/rsCpuScript.cpp b/cpu_ref/rsCpuScript.cpp
index 508381f..16b3ec6 100644
--- a/cpu_ref/rsCpuScript.cpp
+++ b/cpu_ref/rsCpuScript.cpp
@@ -674,6 +674,12 @@
                                         const void * usr, uint32_t usrLen,
                                         const RsScriptCall *sc,
                                         MTLaunchStructForEach *mtls) {
+    if (ains == nullptr && inLen != 0) {
+        mCtx->getContext()->setError(RS_ERROR_BAD_SCRIPT,
+          "rsForEach called with none-zero inLen with null in allocations");
+        return false;
+    }
+
     memset(mtls, 0, sizeof(MTLaunchStructForEach));
     mtls->dimPtr = &mtls->fep.dim;