From 9d5e03db9929271f56ac4a0078d9474d7011efcd Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Tue, 3 Nov 2009 11:25:42 -0800 Subject: 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. --- libs/rs/rsScriptC.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libs/rs/rsScriptC.cpp') 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; } -- cgit v1.2.3-59-g8ed1b