diff options
Diffstat (limited to 'indra/lscript')
-rw-r--r-- | indra/lscript/lscript_execute/lscript_execute.cpp | 72 | ||||
-rw-r--r-- | indra/lscript/lscript_library/lscript_alloc.cpp | 51 | ||||
-rw-r--r-- | indra/lscript/lscript_library/lscript_library.cpp | 2 |
3 files changed, 52 insertions, 73 deletions
diff --git a/indra/lscript/lscript_execute/lscript_execute.cpp b/indra/lscript/lscript_execute/lscript_execute.cpp index 1cbcdc2c58..e56bfd337c 100644 --- a/indra/lscript/lscript_execute/lscript_execute.cpp +++ b/indra/lscript/lscript_execute/lscript_execute.cpp @@ -2577,6 +2577,7 @@ BOOL run_jump(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) offset += arg; return FALSE; } + BOOL run_jumpif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) { if (b_print) @@ -2629,8 +2630,10 @@ BOOL run_jumpif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) else if (type == LST_STRING) { S32 base_address = lscript_pop_int(buffer); - // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization - // and function clean up of ref counts isn't based on scope (a mistake, I know) + // this bit of nastiness is to get around that code paths to + // local variables can result in lack of initialization and + // function clean up of ref counts isn't based on scope (a + // mistake, I know) S32 address = base_address + get_register(buffer, LREG_HR) - 1; if (address) { @@ -2655,8 +2658,10 @@ BOOL run_jumpif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) else if (type == LST_KEY) { S32 base_address = lscript_pop_int(buffer); - // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization - // and function clean up of ref counts isn't based on scope (a mistake, I know) + // this bit of nastiness is to get around that code paths to + // local variables can result in lack of initialization and + // function clean up of ref counts isn't based on scope (a + // mistake, I know) S32 address = base_address + get_register(buffer, LREG_HR) - 1; if (address) { @@ -2672,26 +2677,34 @@ BOOL run_jumpif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) if (strlen(sdata)) /*Flawfinder: ignore*/ { LLUUID id; - id.set(sdata); - if (id != LLUUID::null) + if (id.set(sdata) && id.notNull()) offset += arg; } delete [] sdata; } lsa_decrease_ref_count(buffer, base_address); } - else if (type == LST_LIST) + } + else if (type == LST_LIST) + { + S32 base_address = lscript_pop_int(buffer); + S32 address = base_address + get_register(buffer, LREG_HR) - 1; + if (address) { - S32 address = lscript_pop_int(buffer); - LLScriptLibData *list = lsa_get_data(buffer, address, TRUE); - if (list->getListLength()) + if (safe_heap_check_address(buffer, address + SIZEOF_SCRIPT_ALLOC_ENTRY, 1)) { - offset += arg; + LLScriptLibData *list = lsa_get_list_ptr(buffer, base_address, TRUE); + if (list && list->getListLength()) + { + offset += arg; + } + delete list; } } } return FALSE; } + BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) { if (b_print) @@ -2744,8 +2757,10 @@ BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) else if (type == LST_STRING) { S32 base_address = lscript_pop_int(buffer); - // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization - // and function clean up of ref counts isn't based on scope (a mistake, I know) + // this bit of nastiness is to get around that code paths to + // local variables can result in lack of initialization and + // function clean up of ref counts isn't based on scope (a + // mistake, I know) S32 address = base_address + get_register(buffer, LREG_HR) - 1; if (address) { @@ -2770,8 +2785,10 @@ BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) else if (type == LST_KEY) { S32 base_address = lscript_pop_int(buffer); - // this bit of nastiness is to get around that code paths to local variables can result in lack of initialization - // and function clean up of ref counts isn't based on scope (a mistake, I know) + // this bit of nastiness is to get around that code paths to + // local variables can result in lack of initialization and + // function clean up of ref counts isn't based on scope (a + // mistake, I know) S32 address = base_address + get_register(buffer, LREG_HR) - 1; if (address) { @@ -2787,8 +2804,7 @@ BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) if (strlen(sdata)) /*Flawfinder: ignore*/ { LLUUID id; - id.set(sdata); - if (id == LLUUID::null) + if (!id.set(sdata) || id.isNull()) offset += arg; } else @@ -2799,13 +2815,25 @@ BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) } lsa_decrease_ref_count(buffer, base_address); } - else if (type == LST_LIST) + } + else if (type == LST_LIST) + { + S32 base_address = lscript_pop_int(buffer); + // this bit of nastiness is to get around that code paths to + // local variables can result in lack of initialization and + // function clean up of ref counts isn't based on scope (a + // mistake, I know) + S32 address = base_address + get_register(buffer, LREG_HR) - 1; + if (address) { - S32 address = lscript_pop_int(buffer); - LLScriptLibData *list = lsa_get_data(buffer, address, TRUE); - if (!list->getListLength()) + if (safe_heap_check_address(buffer, address + SIZEOF_SCRIPT_ALLOC_ENTRY, 1)) { - offset += arg; + LLScriptLibData *list = lsa_get_list_ptr(buffer, base_address, TRUE); + if (!list || !list->getListLength()) + { + offset += arg; + } + delete list; } } } diff --git a/indra/lscript/lscript_library/lscript_alloc.cpp b/indra/lscript/lscript_library/lscript_alloc.cpp index f26fef6d77..d98af1ddf3 100644 --- a/indra/lscript/lscript_library/lscript_alloc.cpp +++ b/indra/lscript/lscript_library/lscript_alloc.cpp @@ -982,58 +982,9 @@ S32 lsa_cmp_lists(U8 *buffer, S32 offset1, S32 offset2) S32 length1 = list1->getListLength(); S32 length2 = list2->getListLength(); - - if (length1 != length2) - { - return length1 - length2; - } - - LLScriptLibData *runner1 = list1; - LLScriptLibData *runner2 = list2; - - S32 count = 0; - - while (runner1) - { - if (runner1->mType != runner2->mType) - return count; - - switch(runner1->mType) - { - case LST_INTEGER: - if (runner1->mInteger != runner2->mInteger) - return count; - break; - case LST_FLOATINGPOINT: - if (runner1->mFP != runner2->mFP) - return count; - break; - case LST_KEY: - if (strcmp(runner1->mKey, runner2->mKey)) - return count; - break; - case LST_STRING: - if (strcmp(runner1->mString, runner2->mString)) - return count; - break; - case LST_VECTOR: - if (runner1->mVec != runner2->mVec) - return count; - case LST_QUATERNION: - if (runner1->mQuat != runner2->mQuat) - return count; - break; - default: - break; - } - - runner1 = runner1->mListp; - runner2 = runner2->mListp; - } - delete list1; delete list2; - return 0; + return length1 - length2; } diff --git a/indra/lscript/lscript_library/lscript_library.cpp b/indra/lscript/lscript_library/lscript_library.cpp index eef3621d47..c0472926df 100644 --- a/indra/lscript/lscript_library/lscript_library.cpp +++ b/indra/lscript/lscript_library/lscript_library.cpp @@ -100,7 +100,7 @@ void LLScriptLibrary::init() addFunction(new LLScriptLibraryFunction(10.f, 0.2f, dummy_func, "llSetTexture", NULL, "si", "llSetTexture(string texture, integer face)\nsets the texture of face")); addFunction(new LLScriptLibraryFunction(10.f, 0.2f, dummy_func, "llScaleTexture", NULL, "ffi", "llScaleTexture(float scales, float scalet, integer face)\nsets the texture s, t scales for the chosen face")); addFunction(new LLScriptLibraryFunction(10.f, 0.2f, dummy_func, "llOffsetTexture", NULL, "ffi", "llOffsetTexture(float offsets, float offsett, integer face)\nsets the texture s, t offsets for the chosen face")); - addFunction(new LLScriptLibraryFunction(10.f, 0.2f, dummy_func, "llRotateTexture", NULL, "fi", "llOffsetTexture(float rotation, integer face)\nsets the texture rotation for the chosen face")); + addFunction(new LLScriptLibraryFunction(10.f, 0.2f, dummy_func, "llRotateTexture", NULL, "fi", "llRotateTexture(float rotation, integer face)\nsets the texture rotation for the chosen face")); addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llGetTexture", "s", "i", "string llGetTexture(integer face)\ngets the texture of face (if it's a texture in the object inventory, otherwise the key in a string)")); addFunction(new LLScriptLibraryFunction(10.f, 0.2f, dummy_func, "llSetPos", NULL, "v", "llSetPos(vector pos)\nsets the position (if the script isn't physical)")); addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llGetPos", "v", NULL, "vector llGetPos()\ngets the position (if the script isn't physical)")); |