Merge "Delete sampler optimization." into jb-mr2-dev
diff --git a/rsScript.cpp b/rsScript.cpp
index 4b2765a..f2fc5ba 100644
--- a/rsScript.cpp
+++ b/rsScript.cpp
@@ -166,6 +166,13 @@
                        const void *params, size_t paramLen,
                        const RsScriptCall *sc, size_t scLen) {
     Script *s = static_cast<Script *>(vs);
+    // The rs.spec generated code does not handle the absence of an actual
+    // input for sc. Instead, it retains an existing pointer value (the prior
+    // field in the packed data object). This can cause confusion because
+    // drivers might now inspect bogus sc data.
+    if (scLen == 0) {
+        sc = NULL;
+    }
     s->runForEach(rsc, slot,
                   static_cast<const Allocation *>(vain), static_cast<Allocation *>(vaout),
                   params, paramLen, sc);