]> OCCT Git - occt-copy.git/commitdiff
0003513: There is no check for boundary of array in method Set for array attributes
authorszy <szy@opencascade.com>
Wed, 7 Aug 2013 15:27:29 +0000 (19:27 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 15 Aug 2013 13:23:17 +0000 (17:23 +0400)
- Added check of array's boundary in Set(i, val) methods.
- Added comments to cdl files.
- removed accidental modification in TDataStd_ExtStringArray::Value(i).
- recovering accidentally lost modifications.

src/TDataStd/TDataStd_BooleanArray.cdl
src/TDataStd/TDataStd_BooleanArray.cxx
src/TDataStd/TDataStd_ByteArray.cdl
src/TDataStd/TDataStd_ByteArray.cxx
src/TDataStd/TDataStd_ExtStringArray.cdl
src/TDataStd/TDataStd_IntegerArray.cdl
src/TDataStd/TDataStd_IntegerArray.cxx
src/TDataStd/TDataStd_RealArray.cdl
src/TDataStd/TDataStd_RealArray.cxx
src/TDataStd/TDataStd_ReferenceArray.cdl
src/TDataStd/TDataStd_ReferenceArray.cxx

index fe9a08c61ff97aeb9e1016d30fb2a1faf7c8e258..c520a7064a8b6515ccb63e29598b0312ae0ca888 100755 (executable)
@@ -58,6 +58,7 @@ is
              index :Integer from Standard; 
              value : Boolean from Standard);
     ---Purpose: Sets the <Index>th element of the array to <Value>
+    -- OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal  array.
 
     Value (me; 
           Index : Integer from Standard)
index 8092c52a6459e01e3f970e7bbdac79c31e4af8cf..895355a723bc3dbc1e980aba8afd21058346553e 100755 (executable)
@@ -110,13 +110,9 @@ Handle(TDataStd_BooleanArray) TDataStd_BooleanArray::Set(const TDF_Label&
 void TDataStd_BooleanArray::SetValue (const Standard_Integer index,
                                      const Standard_Boolean value) 
 {
-#ifdef DEB
-  if (myValues.IsNull()) 
-    return;
-  if (index < myLower || index > myUpper)
-    return;
-#endif
 
+  if (myValues.IsNull()) 
+    return; 
   Standard_Integer byte_index = (index - myLower) >> 3;
   Standard_Integer degree = index - (byte_index << 3) - myLower;
   Standard_Integer byte_value = DegreeOf2(degree);
index 7d16c3e345c1a74a206d76c9c7f0ebd1c106529c..54af7f1759d3cb4b08f1928c5d83feb7a51c3e49 100755 (executable)
@@ -62,6 +62,7 @@ is
              index :Integer from Standard; 
              value : Byte from Standard);
     ---Purpose: Sets the <Index>th element of the array to <Value>
+    -- OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal  array.
 
     Value (me; 
           Index : Integer from Standard)
index 2a5e749388d8baf40de1c3164f200ec90d72b54e..2c946924c8e99c38564edf199d153c00fdb50637 100755 (executable)
@@ -79,6 +79,8 @@ Handle(TDataStd_ByteArray) TDataStd_ByteArray::Set(const TDF_Label&       label,
 void TDataStd_ByteArray::SetValue (const Standard_Integer index,
                                   const Standard_Byte value) 
 {
+  if (myValue.IsNull()) 
+    return;
   if (value == myValue->Value(index))
     return;
   Backup();
index 693e4bb54c1e02429a95672ebc2d03d6092acc46..63911509e7281ba2225ed571c49891874459c027 100755 (executable)
@@ -60,6 +60,7 @@ is
 
     SetValue (me : mutable; Index : Integer from Standard; Value : ExtendedString from TCollection);
     ---Purpose: Sets  the   <Index>th  element  of   the  array to <Value>
+    -- OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal  array.
 
     Value (me; Index : Integer from Standard)
     ---Purpose: Returns the value of  the  <Index>th element of the array
index 3df9d7da2da877f5dffb176bbad322a9b4c470d1..0aa00baf387b89053cafe8462fe66f472e67f819 100755 (executable)
@@ -60,6 +60,7 @@ is
 
     SetValue (me : mutable; Index, Value : Integer from Standard);
     ---Purpose: Sets  the   <Index>th  element  of   the  array to <Value>
+    -- OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal  array.
 
     Value (me; Index : Integer from Standard)
     ---Purpose: Return the value of  the  <Index>th element of the array
index 1c11154225269d5e9c65726d316c2f1658ebb330..3083ace65ca4acf8103012d6a21bfc75393f2d51 100755 (executable)
@@ -95,7 +95,7 @@ void TDataStd_IntegerArray::SetValue(const Standard_Integer index, const Standar
 {
   if(myValue.IsNull()) return;
   if( myValue->Value(index) == value)
-    return; 
+    return;
   Backup();
   myValue->SetValue(index, value);
 }
index 1696e1a0c93ec7eae3c9ac43e692e246fde79ea2..97171d44f14257cb2b77e2e15e733606b1ffb92f 100755 (executable)
@@ -59,6 +59,7 @@ is
 
     SetValue (me : mutable; Index :Integer from Standard; Value : Real from Standard);
     ---Purpose: Sets  the   <Index>th  element  of   the  array to <Value>
+    -- OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal  array.
 
     Value (me; Index : Integer from Standard)
     ---Purpose: Return the value of  the  <Index>th element of the array
index 86d558a87e09530817bbf4a66cbc06856b075c1c..02e60fea50bf92a9ea6efbfff7026171a0fbf6b0 100755 (executable)
@@ -94,8 +94,7 @@ void TDataStd_RealArray::SetValue (const Standard_Integer index,
   // OCC2932 correction
   if(myValue.IsNull()) return;
   if(myValue->Value(index) == value)
-    return; 
-
+    return;  
   Backup();
   myValue->SetValue(index, value);
 }
index 595bc98ab8db7f5c3532de1e2e64d902380567e5..7b51855a19f155c498339bc06544e0491867a327 100755 (executable)
@@ -59,6 +59,7 @@ is
              index :Integer from Standard; 
              value : Label from TDF);
     ---Purpose: Sets the <Index>th element of the array to <Value>
+    -- OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal  array.
 
     Value (me; 
           Index : Integer from Standard)
index 2a3547d884f45b3971a4f3b78a4f7de02deb1fd2..4b6e2eff071eda3d13da41c84b6363394cd7b162 100755 (executable)
@@ -80,9 +80,9 @@ Handle(TDataStd_ReferenceArray) TDataStd_ReferenceArray::Set(const TDF_Label&
 void TDataStd_ReferenceArray::SetValue (const Standard_Integer index,
                                        const TDF_Label&       value) 
 {
+  if(myArray.IsNull()) return;
   if (value == myArray->Value(index))
     return;
-
   Backup();
 
   myArray->SetValue(index, value);
@@ -144,7 +144,7 @@ const Handle(TDataStd_HLabelArray1)& TDataStd_ReferenceArray::InternalArray () c
 //purpose  : 
 //=======================================================================
 void TDataStd_ReferenceArray::SetInternalArray (const Handle(TDataStd_HLabelArray1)& values,
-                                               const Standard_Boolean /*isCheckItem*/)
+                                               const Standard_Boolean isCheckItem)
 {
 //  myArray = values;
   Standard_Integer aLower    = values->Lower();