aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/lscript/lscript_library/lscript_alloc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/lscript/lscript_library/lscript_alloc.cpp')
-rw-r--r--linden/indra/lscript/lscript_library/lscript_alloc.cpp87
1 files changed, 21 insertions, 66 deletions
diff --git a/linden/indra/lscript/lscript_library/lscript_alloc.cpp b/linden/indra/lscript/lscript_library/lscript_alloc.cpp
index 4636c0b..b39cd1f 100644
--- a/linden/indra/lscript/lscript_library/lscript_alloc.cpp
+++ b/linden/indra/lscript/lscript_library/lscript_alloc.cpp
@@ -127,10 +127,10 @@ S32 lsa_heap_add_data(U8 *buffer, LLScriptLibData *data, S32 heapsize, BOOL b_de
127 size = 4; 127 size = 4;
128 break; 128 break;
129 case LST_KEY: 129 case LST_KEY:
130 size = (S32)strlen(data->mKey) + 1; 130 size = (S32)strlen(data->mKey) + 1; /*Flawfinder: ignore*/
131 break; 131 break;
132 case LST_STRING: 132 case LST_STRING:
133 size = (S32)strlen(data->mString) + 1; 133 size = (S32)strlen(data->mString) + 1; /*Flawfinder: ignore*/
134 break; 134 break;
135 case LST_LIST: 135 case LST_LIST:
136 // list data 4 bytes of number of entries followed by number of pointer 136 // list data 4 bytes of number of entries followed by number of pointer
@@ -354,7 +354,7 @@ S32 lsa_create_data_block(U8 **buffer, LLScriptLibData *data, S32 base_offset)
354 { 354 {
355 if (data->mString) 355 if (data->mString)
356 { 356 {
357 size = (S32)strlen(data->mString) + 1; 357 size = (S32)strlen(data->mString) + 1; /*Flawfinder: ignore*/
358 } 358 }
359 else 359 else
360 { 360 {
@@ -365,7 +365,7 @@ S32 lsa_create_data_block(U8 **buffer, LLScriptLibData *data, S32 base_offset)
365 { 365 {
366 if (data->mKey) 366 if (data->mKey)
367 { 367 {
368 size = (S32)strlen(data->mKey) + 1; 368 size = (S32)strlen(data->mKey) + 1; /*Flawfinder: ignore*/
369 } 369 }
370 else 370 else
371 { 371 {
@@ -432,8 +432,12 @@ S32 lsa_create_data_block(U8 **buffer, LLScriptLibData *data, S32 base_offset)
432 if (listsize) 432 if (listsize)
433 { 433 {
434 U8 *tbuff = new U8[size + listsize]; 434 U8 *tbuff = new U8[size + listsize];
435 memcpy(tbuff, *buffer, size); 435 if (tbuff == NULL)
436 memcpy(tbuff + size, listbuf, listsize); 436 {
437 llerrs << "Memory Allocation Failed" << llendl;
438 }
439 memcpy(tbuff, *buffer, size); /*Flawfinder: ignore*/
440 memcpy(tbuff + size, listbuf, listsize); /*Flawfinder: ignore*/
437 size += listsize; 441 size += listsize;
438 delete [] *buffer; 442 delete [] *buffer;
439 delete [] listbuf; 443 delete [] listbuf;
@@ -516,7 +520,7 @@ void lsa_decrease_ref_count(U8 *buffer, S32 offset)
516 alloc_entry2bytestream(buffer, orig_offset, entry); 520 alloc_entry2bytestream(buffer, orig_offset, entry);
517} 521}
518 522
519char gLSAStringRead[16384]; 523char gLSAStringRead[16384]; /*Flawfinder: ignore*/
520 524
521 525
522LLScriptLibData *lsa_get_data(U8 *buffer, S32 &offset, BOOL b_dec_ref) 526LLScriptLibData *lsa_get_data(U8 *buffer, S32 &offset, BOOL b_dec_ref)
@@ -557,13 +561,13 @@ LLScriptLibData *lsa_get_data(U8 *buffer, S32 &offset, BOOL b_dec_ref)
557 break; 561 break;
558 case LST_KEY: 562 case LST_KEY:
559 bytestream2char(gLSAStringRead, buffer, offset); 563 bytestream2char(gLSAStringRead, buffer, offset);
560 retval->mKey = new char[strlen(gLSAStringRead) + 1]; 564 retval->mKey = new char[strlen(gLSAStringRead) + 1]; /*Flawfinder: ignore*/
561 strcpy(retval->mKey, gLSAStringRead); 565 strcpy(retval->mKey, gLSAStringRead); /*Flawfinder: ignore*/
562 break; 566 break;
563 case LST_STRING: 567 case LST_STRING:
564 bytestream2char(gLSAStringRead, buffer, offset); 568 bytestream2char(gLSAStringRead, buffer, offset);
565 retval->mString = new char[strlen(gLSAStringRead) + 1]; 569 retval->mString = new char[strlen(gLSAStringRead) + 1]; /*Flawfinder: ignore*/
566 strcpy(retval->mString, gLSAStringRead); 570 strcpy(retval->mString, gLSAStringRead); /*Flawfinder: ignore*/
567 break; 571 break;
568 case LST_VECTOR: 572 case LST_VECTOR:
569 bytestream2vector(retval->mVec, buffer, offset); 573 bytestream2vector(retval->mVec, buffer, offset);
@@ -703,13 +707,13 @@ S32 lsa_cat_strings(U8 *buffer, S32 offset1, S32 offset2, S32 heapsize)
703 return 0; 707 return 0;
704 } 708 }
705 709
706 S32 size = (S32)strlen(test1) + (S32)strlen(test2) + 1; 710 S32 size = (S32)strlen(test1) + (S32)strlen(test2) + 1; /*Flawfinder: ignore*/
707 711
708 LLScriptLibData *string3 = new LLScriptLibData; 712 LLScriptLibData *string3 = new LLScriptLibData;
709 string3->mType = LST_STRING; 713 string3->mType = LST_STRING;
710 string3->mString = new char[size]; 714 string3->mString = new char[size];
711 strcpy(string3->mString, test1); 715 strcpy(string3->mString, test1); /*Flawfinder: ignore*/
712 strcat(string3->mString, test2); 716 strcat(string3->mString, test2); /*Flawfinder: ignore*/
713 717
714 delete string1; 718 delete string1;
715 delete string2; 719 delete string2;
@@ -779,7 +783,7 @@ void lsa_print_heap(U8 *buffer)
779 F32 fpvalue; 783 F32 fpvalue;
780 LLVector3 vvalue; 784 LLVector3 vvalue;
781 LLQuaternion qvalue; 785 LLQuaternion qvalue;
782 char string[4096]; 786 char string[4096]; /*Flawfinder: ignore*/
783 787
784 LLScriptAllocEntry entry; 788 LLScriptAllocEntry entry;
785 789
@@ -849,7 +853,7 @@ void lsa_fprint_heap(U8 *buffer, FILE *fp)
849 F32 fpvalue; 853 F32 fpvalue;
850 LLVector3 vvalue; 854 LLVector3 vvalue;
851 LLQuaternion qvalue; 855 LLQuaternion qvalue;
852 char string[4096]; 856 char string[4096]; /*Flawfinder: ignore*/
853 857
854 LLScriptAllocEntry entry; 858 LLScriptAllocEntry entry;
855 859
@@ -997,58 +1001,9 @@ S32 lsa_cmp_lists(U8 *buffer, S32 offset1, S32 offset2)
997 1001
998 S32 length1 = list1->getListLength(); 1002 S32 length1 = list1->getListLength();
999 S32 length2 = list2->getListLength(); 1003 S32 length2 = list2->getListLength();
1000
1001 if (length1 != length2)
1002 {
1003 return length1 - length2;
1004 }
1005
1006 LLScriptLibData *runner1 = list1;
1007 LLScriptLibData *runner2 = list2;
1008
1009 S32 count = 0;
1010
1011 while (runner1)
1012 {
1013 if (runner1->mType != runner2->mType)
1014 return count;
1015
1016 switch(runner1->mType)
1017 {
1018 case LST_INTEGER:
1019 if (runner1->mInteger != runner2->mInteger)
1020 return count;
1021 break;
1022 case LST_FLOATINGPOINT:
1023 if (runner1->mFP != runner2->mFP)
1024 return count;
1025 break;
1026 case LST_KEY:
1027 if (strcmp(runner1->mKey, runner2->mKey))
1028 return count;
1029 break;
1030 case LST_STRING:
1031 if (strcmp(runner1->mString, runner2->mString))
1032 return count;
1033 break;
1034 case LST_VECTOR:
1035 if (runner1->mVec != runner2->mVec)
1036 return count;
1037 case LST_QUATERNION:
1038 if (runner1->mQuat != runner2->mQuat)
1039 return count;
1040 break;
1041 default:
1042 break;
1043 }
1044
1045 runner1 = runner1->mListp;
1046 runner2 = runner2->mListp;
1047 }
1048
1049 delete list1; 1004 delete list1;
1050 delete list2; 1005 delete list2;
1051 return 0; 1006 return length1 - length2;
1052} 1007}
1053 1008
1054 1009