Fix script init error handling.
Change-Id: I7ceb0af4dfd12db0274985ff658f678d7af829ff
diff --git a/libs/rs/rsScript.cpp b/libs/rs/rsScript.cpp
index 16446dd..7fc128e 100644
--- a/libs/rs/rsScript.cpp
+++ b/libs/rs/rsScript.cpp
@@ -26,6 +26,7 @@
mSlots = NULL;
mTypes = NULL;
+ mInitialized = false;
}
Script::~Script() {
diff --git a/libs/rs/rsScript.h b/libs/rs/rsScript.h
index abb55b8..976ae78 100644
--- a/libs/rs/rsScript.h
+++ b/libs/rs/rsScript.h
@@ -85,6 +85,7 @@
virtual void setupScript(Context *rsc) = 0;
virtual uint32_t run(Context *) = 0;
protected:
+ bool mInitialized;
ObjectBaseRef<Allocation> *mSlots;
ObjectBaseRef<const Type> *mTypes;
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index b45366b..a5b1902 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -44,8 +44,10 @@
BT = NULL;
}
#endif
- mRSC->mHal.funcs.script.invokeFreeChildren(mRSC, this);
- mRSC->mHal.funcs.script.destroy(mRSC, this);
+ if (mInitialized) {
+ mRSC->mHal.funcs.script.invokeFreeChildren(mRSC, this);
+ mRSC->mHal.funcs.script.destroy(mRSC, this);
+ }
}
void ScriptC::setupScript(Context *rsc) {
@@ -212,8 +214,11 @@
bitcodeLen = BT->getTranslatedBitcodeSize();
#endif
- rsc->mHal.funcs.script.init(rsc, this, resName, cacheDir, bitcode, bitcodeLen, 0);
+ if (!rsc->mHal.funcs.script.init(rsc, this, resName, cacheDir, bitcode, bitcodeLen, 0)) {
+ return false;
+ }
+ mInitialized = true;
mEnviroment.mFragment.set(rsc->getDefaultProgramFragment());
mEnviroment.mVertex.set(rsc->getDefaultProgramVertex());
mEnviroment.mFragmentStore.set(rsc->getDefaultProgramStore());