diff options
Diffstat (limited to 'linden/indra/lscript/lscript_library/lscript_alloc.cpp')
-rw-r--r-- | linden/indra/lscript/lscript_library/lscript_alloc.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/linden/indra/lscript/lscript_library/lscript_alloc.cpp b/linden/indra/lscript/lscript_library/lscript_alloc.cpp index a39edda..2c37d22 100644 --- a/linden/indra/lscript/lscript_library/lscript_alloc.cpp +++ b/linden/indra/lscript/lscript_library/lscript_alloc.cpp | |||
@@ -131,10 +131,12 @@ S32 lsa_heap_add_data(U8 *buffer, LLScriptLibData *data, S32 heapsize, BOOL b_de | |||
131 | size = 4; | 131 | size = 4; |
132 | break; | 132 | break; |
133 | case LST_KEY: | 133 | case LST_KEY: |
134 | size = (S32)strlen(data->mKey) + 1; /*Flawfinder: ignore*/ | 134 | // NOTE: babbage: defensive as some library calls set data to NULL |
135 | size = data->mKey ? (S32)strlen(data->mKey) + 1 : 1; /*Flawfinder: ignore*/ | ||
135 | break; | 136 | break; |
136 | case LST_STRING: | 137 | case LST_STRING: |
137 | size = (S32)strlen(data->mString) + 1; /*Flawfinder: ignore*/ | 138 | // NOTE: babbage: defensive as some library calls set data to NULL |
139 | size = data->mString ? (S32)strlen(data->mString) + 1 : 1; /*Flawfinder: ignore*/ | ||
138 | break; | 140 | break; |
139 | case LST_LIST: | 141 | case LST_LIST: |
140 | // list data 4 bytes of number of entries followed by number of pointer | 142 | // list data 4 bytes of number of entries followed by number of pointer |
@@ -294,10 +296,10 @@ void lsa_insert_data(U8 *buffer, S32 &offset, LLScriptLibData *data, LLScriptAll | |||
294 | float2bytestream(buffer, offset, data->mFP); | 296 | float2bytestream(buffer, offset, data->mFP); |
295 | break; | 297 | break; |
296 | case LST_KEY: | 298 | case LST_KEY: |
297 | char2bytestream(buffer, offset, data->mKey); | 299 | char2bytestream(buffer, offset, data->mKey ? data->mKey : ""); |
298 | break; | 300 | break; |
299 | case LST_STRING: | 301 | case LST_STRING: |
300 | char2bytestream(buffer, offset, data->mString); | 302 | char2bytestream(buffer, offset, data->mString ? data->mString : ""); |
301 | break; | 303 | break; |
302 | case LST_VECTOR: | 304 | case LST_VECTOR: |
303 | vector2bytestream(buffer, offset, data->mVec); | 305 | vector2bytestream(buffer, offset, data->mVec); |
@@ -524,7 +526,7 @@ void lsa_decrease_ref_count(U8 *buffer, S32 offset) | |||
524 | alloc_entry2bytestream(buffer, orig_offset, entry); | 526 | alloc_entry2bytestream(buffer, orig_offset, entry); |
525 | } | 527 | } |
526 | 528 | ||
527 | char gLSAStringRead[16384]; /*Flawfinder: ignore*/ | 529 | char gLSAStringRead[TOP_OF_MEMORY]; /*Flawfinder: ignore*/ |
528 | 530 | ||
529 | 531 | ||
530 | LLScriptLibData *lsa_get_data(U8 *buffer, S32 &offset, BOOL b_dec_ref) | 532 | LLScriptLibData *lsa_get_data(U8 *buffer, S32 &offset, BOOL b_dec_ref) |
@@ -564,12 +566,12 @@ LLScriptLibData *lsa_get_data(U8 *buffer, S32 &offset, BOOL b_dec_ref) | |||
564 | retval->mFP = bytestream2float(buffer, offset); | 566 | retval->mFP = bytestream2float(buffer, offset); |
565 | break; | 567 | break; |
566 | case LST_KEY: | 568 | case LST_KEY: |
567 | bytestream2char(gLSAStringRead, buffer, offset); | 569 | bytestream2char(gLSAStringRead, buffer, offset, sizeof(gLSAStringRead)); // global sring buffer? for real? :( |
568 | retval->mKey = new char[strlen(gLSAStringRead) + 1]; /*Flawfinder: ignore*/ | 570 | retval->mKey = new char[strlen(gLSAStringRead) + 1]; /*Flawfinder: ignore*/ |
569 | strcpy(retval->mKey, gLSAStringRead); /*Flawfinder: ignore*/ | 571 | strcpy(retval->mKey, gLSAStringRead); /*Flawfinder: ignore*/ |
570 | break; | 572 | break; |
571 | case LST_STRING: | 573 | case LST_STRING: |
572 | bytestream2char(gLSAStringRead, buffer, offset); | 574 | bytestream2char(gLSAStringRead, buffer, offset, sizeof(gLSAStringRead)); |
573 | retval->mString = new char[strlen(gLSAStringRead) + 1]; /*Flawfinder: ignore*/ | 575 | retval->mString = new char[strlen(gLSAStringRead) + 1]; /*Flawfinder: ignore*/ |
574 | strcpy(retval->mString, gLSAStringRead); /*Flawfinder: ignore*/ | 576 | strcpy(retval->mString, gLSAStringRead); /*Flawfinder: ignore*/ |
575 | break; | 577 | break; |
@@ -816,11 +818,11 @@ void lsa_print_heap(U8 *buffer) | |||
816 | printf("%f\n", fpvalue); | 818 | printf("%f\n", fpvalue); |
817 | break; | 819 | break; |
818 | case LST_STRING: | 820 | case LST_STRING: |
819 | bytestream2char(string, buffer, readoffset); | 821 | bytestream2char(string, buffer, readoffset, sizeof(string)); |
820 | printf("%s\n", string); | 822 | printf("%s\n", string); |
821 | break; | 823 | break; |
822 | case LST_KEY: | 824 | case LST_KEY: |
823 | bytestream2char(string, buffer, readoffset); | 825 | bytestream2char(string, buffer, readoffset, sizeof(string)); |
824 | printf("%s\n", string); | 826 | printf("%s\n", string); |
825 | break; | 827 | break; |
826 | case LST_VECTOR: | 828 | case LST_VECTOR: |
@@ -883,11 +885,11 @@ void lsa_fprint_heap(U8 *buffer, FILE *fp) | |||
883 | fprintf(fp, "%f\n", fpvalue); | 885 | fprintf(fp, "%f\n", fpvalue); |
884 | break; | 886 | break; |
885 | case LST_STRING: | 887 | case LST_STRING: |
886 | bytestream2char(string, buffer, readoffset); | 888 | bytestream2char(string, buffer, readoffset, sizeof(string)); |
887 | fprintf(fp, "%s\n", string); | 889 | fprintf(fp, "%s\n", string); |
888 | break; | 890 | break; |
889 | case LST_KEY: | 891 | case LST_KEY: |
890 | bytestream2char(string, buffer, readoffset); | 892 | bytestream2char(string, buffer, readoffset, sizeof(string)); |
891 | fprintf(fp, "%s\n", string); | 893 | fprintf(fp, "%s\n", string); |
892 | break; | 894 | break; |
893 | case LST_VECTOR: | 895 | case LST_VECTOR: |