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
diff --git a/driver/rsdBcc.cpp b/driver/rsdBcc.cpp
index 2038a4c..6c5a55b 100644
--- a/driver/rsdBcc.cpp
+++ b/driver/rsdBcc.cpp
@@ -522,7 +522,11 @@
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;