diff options
| author | 2009-11-03 11:25:42 -0800 | |
|---|---|---|
| committer | 2009-11-03 11:25:42 -0800 | |
| commit | 9d5e03db9929271f56ac4a0078d9474d7011efcd (patch) | |
| tree | 8052ee61aa0c6b7a1fc1ebdfcee1ea8f32a3dd5b /libs/rs/rsScriptC.cpp | |
| parent | c4918c30147d72c44e9a2a9fe7b9cbe88948677a (diff) | |
Fix RS bugs. We were holding a pointer to the script text from the java vm. Move freeing of objects to before context teardown to allow allocations to clean up their data.
Diffstat (limited to 'libs/rs/rsScriptC.cpp')
| -rw-r--r-- | libs/rs/rsScriptC.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index 9da7766217b6..073d98bf4e1b 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -46,6 +46,8 @@ ScriptC::~ScriptC() if (mAccScript) { accDeleteScript(mAccScript); } + free(mEnviroment.mScriptText); + mEnviroment.mScriptText = NULL; } void ScriptC::setupScript() @@ -404,7 +406,11 @@ void rsi_ScriptCSetScript(Context * rsc, void *vp) void rsi_ScriptCSetText(Context *rsc, const char *text, uint32_t len) { ScriptCState *ss = &rsc->mScriptC; - ss->mScript->mEnviroment.mScriptText = text; + + char *t = (char *)malloc(len + 1); + memcpy(t, text, len); + t[len] = 0; + ss->mScript->mEnviroment.mScriptText = t; ss->mScript->mEnviroment.mScriptTextLength = len; } |