]> git.mxchange.org Git - simgear.git/commitdiff
DrawElementsFacade: use ref_ptr instead of mismatched new/free
authorRebecca N. Palmer <rebecca_palmer@zoho.com>
Thu, 12 Feb 2015 15:48:36 +0000 (15:48 +0000)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Thu, 12 Feb 2015 15:48:36 +0000 (15:48 +0000)
Found by AddressSanitizer; not seen to crash, but probably best fixed

simgear/scene/tgdb/SGTexturedTriangleBin.hxx

index 79f7459c05b089b6814d172781479571e6ad433d..b2fb3cd5dfec5949f96587e8ad3268f123647ea5 100644 (file)
@@ -28,6 +28,7 @@
 #include <osg/Geometry>
 #include <osg/PrimitiveSet>
 #include <osg/Texture2D>
+#include <osg/ref_ptr>
 #include <stdio.h>
 
 #include <simgear/math/sg_random.h>
@@ -122,16 +123,16 @@ public:
     osg::DrawElements* getDrawElements()
     {
         if (count > 65535) {
-            free (_ushortElements);
+            _ushortElements = 0;
             return _uintElements;
         } else {
-            free (_uintElements);
+            _uintElements = 0;
             return _ushortElements;
         }
     }
 protected:
-    osg::DrawElementsUShort* _ushortElements;
-    osg::DrawElementsUInt* _uintElements;
+    osg::ref_ptr<osg::DrawElementsUShort> _ushortElements;
+    osg::ref_ptr<osg::DrawElementsUInt> _uintElements;
     unsigned count;
 };