Properly handle script teardown.

If libbcc optimizes away a global variable, we need to make sure that
RenderScript's ~Context() doesn't attempt to clear away the slot's NULL
pointer that denotes this.

Change-Id: I77d0f740ab333338e53db481e4a3eca338aba411
This commit is contained in:
Stephen Hines
2011-03-24 20:03:49 -07:00
parent 70a1705556
commit 623cb9585e

View File

@@ -522,7 +522,11 @@ void rsdScriptDestroy(const Context *dc, Script *script) {
if (drv->mFieldAddress) {
for (size_t ct=0; ct < drv->mFieldCount; ct++) {
if (drv->mFieldIsObject[ct]) {
rsiClearObject((ObjectBase **)&drv->mFieldAddress[ct]);
// The field address can be NULL if the script-side has
// optimized the corresponding global variable away.
if (drv->mFieldAddress[ct]) {
rsiClearObject((ObjectBase **)drv->mFieldAddress[ct]);
}
}
}
delete [] drv->mFieldAddress;