aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorMelanie Thielker2015-08-24 00:08:08 +0200
committerMelanie Thielker2015-08-24 00:08:08 +0200
commit87247dc2c9c649693e4e0c4469865fdba5e69025 (patch)
treecc87e284984b222d63c46d29e4884e7cef773b5e /OpenSim/Region/ScriptEngine
parentRevert "Revert "Fix a possible nullref caused by accessing m_data rather than... (diff)
downloadopensim-SC_OLD-87247dc2c9c649693e4e0c4469865fdba5e69025.zip
opensim-SC_OLD-87247dc2c9c649693e4e0c4469865fdba5e69025.tar.gz
opensim-SC_OLD-87247dc2c9c649693e4e0c4469865fdba5e69025.tar.bz2
opensim-SC_OLD-87247dc2c9c649693e4e0c4469865fdba5e69025.tar.xz
Just replace all m_data accesses with accesses to Data, which is
protected against nullrefs
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs124
1 files changed, 62 insertions, 62 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index d6f5102..94277bb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -581,7 +581,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
581 /// <param name='itemIndex'></param> 581 /// <param name='itemIndex'></param>
582 public Type GetLSLListItemType(int itemIndex) 582 public Type GetLSLListItemType(int itemIndex)
583 { 583 {
584 return m_data[itemIndex].GetType(); 584 return Data[itemIndex].GetType();
585 } 585 }
586 586
587 /// <summary> 587 /// <summary>
@@ -598,107 +598,107 @@ namespace OpenSim.Region.ScriptEngine.Shared
598 /// <param name='itemIndex'></param> 598 /// <param name='itemIndex'></param>
599 public LSL_Types.LSLFloat GetLSLFloatItem(int itemIndex) 599 public LSL_Types.LSLFloat GetLSLFloatItem(int itemIndex)
600 { 600 {
601 if (m_data[itemIndex] is LSL_Types.LSLInteger) 601 if (Data[itemIndex] is LSL_Types.LSLInteger)
602 { 602 {
603 return (LSL_Types.LSLInteger)m_data[itemIndex]; 603 return (LSL_Types.LSLInteger)Data[itemIndex];
604 } 604 }
605 else if (m_data[itemIndex] is Int32) 605 else if (Data[itemIndex] is Int32)
606 { 606 {
607 return new LSL_Types.LSLFloat((int)m_data[itemIndex]); 607 return new LSL_Types.LSLFloat((int)Data[itemIndex]);
608 } 608 }
609 else if (m_data[itemIndex] is float) 609 else if (Data[itemIndex] is float)
610 { 610 {
611 return new LSL_Types.LSLFloat((float)m_data[itemIndex]); 611 return new LSL_Types.LSLFloat((float)Data[itemIndex]);
612 } 612 }
613 else if (m_data[itemIndex] is Double) 613 else if (Data[itemIndex] is Double)
614 { 614 {
615 return new LSL_Types.LSLFloat((Double)m_data[itemIndex]); 615 return new LSL_Types.LSLFloat((Double)Data[itemIndex]);
616 } 616 }
617 else if (m_data[itemIndex] is LSL_Types.LSLString) 617 else if (Data[itemIndex] is LSL_Types.LSLString)
618 { 618 {
619 return new LSL_Types.LSLFloat(m_data[itemIndex].ToString()); 619 return new LSL_Types.LSLFloat(Data[itemIndex].ToString());
620 } 620 }
621 else 621 else
622 { 622 {
623 return (LSL_Types.LSLFloat)m_data[itemIndex]; 623 return (LSL_Types.LSLFloat)Data[itemIndex];
624 } 624 }
625 } 625 }
626 626
627 public LSL_Types.LSLString GetLSLStringItem(int itemIndex) 627 public LSL_Types.LSLString GetLSLStringItem(int itemIndex)
628 { 628 {
629 if (m_data[itemIndex] is LSL_Types.key) 629 if (Data[itemIndex] is LSL_Types.key)
630 { 630 {
631 return (LSL_Types.key)m_data[itemIndex]; 631 return (LSL_Types.key)Data[itemIndex];
632 } 632 }
633 else 633 else
634 { 634 {
635 return new LSL_Types.LSLString(m_data[itemIndex].ToString()); 635 return new LSL_Types.LSLString(Data[itemIndex].ToString());
636 } 636 }
637 } 637 }
638 638
639 public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex) 639 public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex)
640 { 640 {
641 if (m_data[itemIndex] is LSL_Types.LSLInteger) 641 if (Data[itemIndex] is LSL_Types.LSLInteger)
642 return (LSL_Types.LSLInteger)m_data[itemIndex]; 642 return (LSL_Types.LSLInteger)Data[itemIndex];
643 if (m_data[itemIndex] is LSL_Types.LSLFloat) 643 if (Data[itemIndex] is LSL_Types.LSLFloat)
644 return new LSLInteger((int)m_data[itemIndex]); 644 return new LSLInteger((int)Data[itemIndex]);
645 else if (m_data[itemIndex] is Int32) 645 else if (Data[itemIndex] is Int32)
646 return new LSLInteger((int)m_data[itemIndex]); 646 return new LSLInteger((int)Data[itemIndex]);
647 else if (m_data[itemIndex] is LSL_Types.LSLString) 647 else if (Data[itemIndex] is LSL_Types.LSLString)
648 return new LSLInteger(m_data[itemIndex].ToString()); 648 return new LSLInteger(Data[itemIndex].ToString());
649 else 649 else
650 throw new InvalidCastException(string.Format( 650 throw new InvalidCastException(string.Format(
651 "{0} expected but {1} given", 651 "{0} expected but {1} given",
652 typeof(LSL_Types.LSLInteger).Name, 652 typeof(LSL_Types.LSLInteger).Name,
653 m_data[itemIndex] != null ? 653 Data[itemIndex] != null ?
654 m_data[itemIndex].GetType().Name : "null")); 654 Data[itemIndex].GetType().Name : "null"));
655 } 655 }
656 656
657 public LSL_Types.Vector3 GetVector3Item(int itemIndex) 657 public LSL_Types.Vector3 GetVector3Item(int itemIndex)
658 { 658 {
659 if (m_data[itemIndex] is LSL_Types.Vector3) 659 if (Data[itemIndex] is LSL_Types.Vector3)
660 { 660 {
661 return (LSL_Types.Vector3)m_data[itemIndex]; 661 return (LSL_Types.Vector3)Data[itemIndex];
662 } 662 }
663 else if(m_data[itemIndex] is OpenMetaverse.Vector3) 663 else if(Data[itemIndex] is OpenMetaverse.Vector3)
664 { 664 {
665 return new LSL_Types.Vector3( 665 return new LSL_Types.Vector3(
666 (OpenMetaverse.Vector3)m_data[itemIndex]); 666 (OpenMetaverse.Vector3)Data[itemIndex]);
667 } 667 }
668 else 668 else
669 { 669 {
670 throw new InvalidCastException(string.Format( 670 throw new InvalidCastException(string.Format(
671 "{0} expected but {1} given", 671 "{0} expected but {1} given",
672 typeof(LSL_Types.Vector3).Name, 672 typeof(LSL_Types.Vector3).Name,
673 m_data[itemIndex] != null ? 673 Data[itemIndex] != null ?
674 m_data[itemIndex].GetType().Name : "null")); 674 Data[itemIndex].GetType().Name : "null"));
675 } 675 }
676 } 676 }
677 677
678 public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) 678 public LSL_Types.Quaternion GetQuaternionItem(int itemIndex)
679 { 679 {
680 if (m_data[itemIndex] is LSL_Types.Quaternion) 680 if (Data[itemIndex] is LSL_Types.Quaternion)
681 { 681 {
682 return (LSL_Types.Quaternion)m_data[itemIndex]; 682 return (LSL_Types.Quaternion)Data[itemIndex];
683 } 683 }
684 else if(m_data[itemIndex] is OpenMetaverse.Quaternion) 684 else if(Data[itemIndex] is OpenMetaverse.Quaternion)
685 { 685 {
686 return new LSL_Types.Quaternion( 686 return new LSL_Types.Quaternion(
687 (OpenMetaverse.Quaternion)m_data[itemIndex]); 687 (OpenMetaverse.Quaternion)Data[itemIndex]);
688 } 688 }
689 else 689 else
690 { 690 {
691 throw new InvalidCastException(string.Format( 691 throw new InvalidCastException(string.Format(
692 "{0} expected but {1} given", 692 "{0} expected but {1} given",
693 typeof(LSL_Types.Quaternion).Name, 693 typeof(LSL_Types.Quaternion).Name,
694 m_data[itemIndex] != null ? 694 Data[itemIndex] != null ?
695 m_data[itemIndex].GetType().Name : "null")); 695 Data[itemIndex].GetType().Name : "null"));
696 } 696 }
697 } 697 }
698 698
699 public LSL_Types.key GetKeyItem(int itemIndex) 699 public LSL_Types.key GetKeyItem(int itemIndex)
700 { 700 {
701 return (LSL_Types.key)m_data[itemIndex]; 701 return (LSL_Types.key)Data[itemIndex];
702 } 702 }
703 703
704 public static list operator +(list a, list b) 704 public static list operator +(list a, list b)
@@ -794,53 +794,53 @@ namespace OpenSim.Region.ScriptEngine.Shared
794 Object[] ret; 794 Object[] ret;
795 795
796 if (start < 0) 796 if (start < 0)
797 start=m_data.Length+start; 797 start=Data.Length+start;
798 798
799 if (start < 0) 799 if (start < 0)
800 start=0; 800 start=0;
801 801
802 if (end < 0) 802 if (end < 0)
803 end=m_data.Length+end; 803 end=Data.Length+end;
804 if (end < 0) 804 if (end < 0)
805 end=0; 805 end=0;
806 806
807 if (start > end) 807 if (start > end)
808 { 808 {
809 if (end >= m_data.Length) 809 if (end >= Data.Length)
810 return new list(new Object[0]); 810 return new list(new Object[0]);
811 811
812 if (start >= m_data.Length) 812 if (start >= Data.Length)
813 start=m_data.Length-1; 813 start=Data.Length-1;
814 814
815 return GetSublist(end, start); 815 return GetSublist(end, start);
816 } 816 }
817 817
818 // start >= 0 && end >= 0 here 818 // start >= 0 && end >= 0 here
819 if (start >= m_data.Length) 819 if (start >= Data.Length)
820 { 820 {
821 ret=new Object[m_data.Length]; 821 ret=new Object[Data.Length];
822 Array.Copy(m_data, 0, ret, 0, m_data.Length); 822 Array.Copy(Data, 0, ret, 0, Data.Length);
823 823
824 return new list(ret); 824 return new list(ret);
825 } 825 }
826 826
827 if (end >= m_data.Length) 827 if (end >= Data.Length)
828 end=m_data.Length-1; 828 end=Data.Length-1;
829 829
830 // now, this makes the math easier 830 // now, this makes the math easier
831 int remove=end+1-start; 831 int remove=end+1-start;
832 832
833 ret=new Object[m_data.Length-remove]; 833 ret=new Object[Data.Length-remove];
834 if (ret.Length == 0) 834 if (ret.Length == 0)
835 return new list(ret); 835 return new list(ret);
836 836
837 int src; 837 int src;
838 int dest=0; 838 int dest=0;
839 839
840 for (src = 0; src < m_data.Length; src++) 840 for (src = 0; src < Data.Length; src++)
841 { 841 {
842 if (src < start || src > end) 842 if (src < start || src > end)
843 ret[dest++]=m_data[src]; 843 ret[dest++]=Data[src];
844 } 844 }
845 845
846 return new list(ret); 846 return new list(ret);
@@ -860,12 +860,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
860 860
861 if (start < 0) 861 if (start < 0)
862 { 862 {
863 start = m_data.Length + start; 863 start = Data.Length + start;
864 } 864 }
865 865
866 if (end < 0) 866 if (end < 0)
867 { 867 {
868 end = m_data.Length + end; 868 end = Data.Length + end;
869 } 869 }
870 870
871 // The conventional case is start <= end 871 // The conventional case is start <= end
@@ -879,15 +879,15 @@ namespace OpenSim.Region.ScriptEngine.Shared
879 879
880 // Start sublist beyond length 880 // Start sublist beyond length
881 // Also deals with start AND end still negative 881 // Also deals with start AND end still negative
882 if (start >= m_data.Length || end < 0) 882 if (start >= Data.Length || end < 0)
883 { 883 {
884 return new list(); 884 return new list();
885 } 885 }
886 886
887 // Sublist extends beyond the end of the supplied list 887 // Sublist extends beyond the end of the supplied list
888 if (end >= m_data.Length) 888 if (end >= Data.Length)
889 { 889 {
890 end = m_data.Length - 1; 890 end = Data.Length - 1;
891 } 891 }
892 892
893 // Sublist still starts before the beginning of the list 893 // Sublist still starts before the beginning of the list
@@ -898,7 +898,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
898 898
899 ret = new object[end - start + 1]; 899 ret = new object[end - start + 1];
900 900
901 Array.Copy(m_data, start, ret, 0, end - start + 1); 901 Array.Copy(Data, start, ret, 0, end - start + 1);
902 902
903 return new list(ret); 903 return new list(ret);
904 904
@@ -931,7 +931,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
931 931
932 // If start is outside of list, then just return 932 // If start is outside of list, then just return
933 // the prefix, whatever it is. 933 // the prefix, whatever it is.
934 if (start >= m_data.Length) 934 if (start >= Data.Length)
935 { 935 {
936 return result; 936 return result;
937 } 937 }
@@ -1109,11 +1109,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
1109 { 1109 {
1110 string output; 1110 string output;
1111 output = String.Empty; 1111 output = String.Empty;
1112 if (m_data.Length == 0) 1112 if (Data.Length == 0)
1113 { 1113 {
1114 return String.Empty; 1114 return String.Empty;
1115 } 1115 }
1116 foreach (object o in m_data) 1116 foreach (object o in Data)
1117 { 1117 {
1118 output = output + o.ToString(); 1118 output = output + o.ToString();
1119 } 1119 }
@@ -1308,12 +1308,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
1308 public string ToPrettyString() 1308 public string ToPrettyString()
1309 { 1309 {
1310 string output; 1310 string output;
1311 if (m_data.Length == 0) 1311 if (Data.Length == 0)
1312 { 1312 {
1313 return "[]"; 1313 return "[]";
1314 } 1314 }
1315 output = "["; 1315 output = "[";
1316 foreach (object o in m_data) 1316 foreach (object o in Data)
1317 { 1317 {
1318 if (o is String) 1318 if (o is String)
1319 { 1319 {