Validate input/output for a ScriptGroup.
If a script group requires input or output allocations, make sure
they are set before starting the execution of the script group.
If any allocation is missing, skip the execution and set a bad
value error with a message.
Change-Id: I7ee2da96aca3e6c9820225e6b2c39cb9378cb42f
diff --git a/rsScriptGroup.cpp b/rsScriptGroup.cpp
index 17ef211..d1dd9d8 100644
--- a/rsScriptGroup.cpp
+++ b/rsScriptGroup.cpp
@@ -281,7 +281,30 @@
rsAssert(!"ScriptGroup:setOutput kid not found");
}
+bool ScriptGroup::validateInputAndOutput(Context *rsc) {
+ for(size_t i = 0; i < mInputs.size(); i++) {
+ if (mInputs[i]->mAlloc.get() == NULL) {
+ rsc->setError(RS_ERROR_BAD_VALUE, "ScriptGroup missing input.");
+ return false;
+ }
+ }
+
+ for(size_t i = 0; i < mOutputs.size(); i++) {
+ if (mOutputs[i]->mAlloc.get() == NULL) {
+ rsc->setError(RS_ERROR_BAD_VALUE, "ScriptGroup missing output.");
+ return false;
+ }
+ }
+
+ return true;
+}
+
void ScriptGroup::execute(Context *rsc) {
+
+ if (!validateInputAndOutput(rsc)) {
+ return;
+ }
+
//ALOGE("ScriptGroup::execute");
if (rsc->mHal.funcs.scriptgroup.execute) {
rsc->mHal.funcs.scriptgroup.execute(rsc, this);