From: Rebecca N. Palmer Date: Thu, 12 Feb 2015 15:48:36 +0000 (+0000) Subject: DrawElementsFacade: use ref_ptr instead of mismatched new/free X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8c38f799adf4f4ece8c79dd1e6ff5a75d85a17dc;p=simgear.git DrawElementsFacade: use ref_ptr instead of mismatched new/free Found by AddressSanitizer; not seen to crash, but probably best fixed --- diff --git a/simgear/scene/tgdb/SGTexturedTriangleBin.hxx b/simgear/scene/tgdb/SGTexturedTriangleBin.hxx index 79f7459c..b2fb3cd5 100644 --- a/simgear/scene/tgdb/SGTexturedTriangleBin.hxx +++ b/simgear/scene/tgdb/SGTexturedTriangleBin.hxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -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 _ushortElements; + osg::ref_ptr _uintElements; unsigned count; };