]> git.mxchange.org Git - simgear.git/blobdiff - simgear/hla/HLAArrayDataElement.hxx
hla: Fix buffer overrun in SGMath vector types.
[simgear.git] / simgear / hla / HLAArrayDataElement.hxx
index c236c4e442cf3a340330a126768d92ac8855cc69..8f510be59c63a959a406050f34d41e5c859aa87c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 - 2010  Mathias Froehlich - Mathias.Froehlich@web.de
+// Copyright (C) 2009 - 2012  Mathias Froehlich - Mathias.Froehlich@web.de
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Library General Public
@@ -23,7 +23,7 @@
 #include <simgear/math/SGMath.hxx>
 #include "HLAArrayDataType.hxx"
 #include "HLADataElement.hxx"
-#include "HLAVariantDataElement.hxx"
+#include "HLAVariantRecordDataElement.hxx"
 #include "HLADataTypeVisitor.hxx"
 
 namespace simgear {
@@ -102,20 +102,20 @@ public:
     virtual unsigned getNumElements() const;
     virtual bool encodeElement(HLAEncodeStream& stream, unsigned i) const;
 
-    const HLAVariantDataElement* getElement(unsigned index) const;
-    HLAVariantDataElement* getElement(unsigned index);
-    HLAVariantDataElement* getOrCreateElement(unsigned index);
-    void setElement(unsigned index, HLAVariantDataElement* value);
+    const HLAVariantRecordDataElement* getElement(unsigned index) const;
+    HLAVariantRecordDataElement* getElement(unsigned index);
+    HLAVariantRecordDataElement* getOrCreateElement(unsigned index);
+    void setElement(unsigned index, HLAVariantRecordDataElement* value);
 
-    typedef HLAVariantDataElement::DataElementFactory AlternativeDataElementFactory;
+    typedef HLAVariantRecordDataElement::DataElementFactory AlternativeDataElementFactory;
 
     void setAlternativeDataElementFactory(AlternativeDataElementFactory* alternativeDataElementFactory);
     AlternativeDataElementFactory* getAlternativeDataElementFactory();
 
 private:
-    HLAVariantDataElement* newElement();
+    HLAVariantRecordDataElement* newElement();
 
-    typedef std::vector<SGSharedPtr<HLAVariantDataElement> > ElementVector;
+    typedef std::vector<SGSharedPtr<HLAVariantRecordDataElement> > ElementVector;
     ElementVector _elementVector;
 
     SGSharedPtr<AlternativeDataElementFactory> _alternativeDataElementFactory;
@@ -214,7 +214,7 @@ public:
 
     virtual bool setNumElements(unsigned count)
     {
-        for (unsigned i = 2; i < count; ++i)
+        for (unsigned i = count; i < 2; ++i)
             _value[i] = 0;
         return true;
     }
@@ -306,7 +306,7 @@ public:
 
     virtual bool setNumElements(unsigned count)
     {
-        for (unsigned i = 3; i < count; ++i)
+        for (unsigned i = count; i < 3; ++i)
             _value[i] = 0;
         return true;
     }
@@ -398,7 +398,7 @@ public:
 
     virtual bool setNumElements(unsigned count)
     {
-        for (unsigned i = 4; i < count; ++i)
+        for (unsigned i = count; i < 4; ++i)
             _value[i] = 0;
         return true;
     }
@@ -490,7 +490,7 @@ public:
 
     virtual bool setNumElements(unsigned count)
     {
-        for (unsigned i = 4; i < count; ++i)
+        for (unsigned i = count; i < 4; ++i)
             _value[i] = 0;
         return true;
     }