[Liblas-commits] hg-main-tree: dumb fix for memleak

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Aug 15 10:34:18 EDT 2011


details:   http://hg.libpc.orghg-main-tree/rev/483284c82936
changeset: 1089:483284c82936
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Aug 15 07:34:03 2011 -0700
description:
dumb fix for memleak

diffstat:

 src/drivers/las/LasHeaderReader.cpp |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (25 lines):

diff -r 796b179c92df -r 483284c82936 src/drivers/las/LasHeaderReader.cpp
--- a/src/drivers/las/LasHeaderReader.cpp	Mon Aug 15 07:12:43 2011 -0700
+++ b/src/drivers/las/LasHeaderReader.cpp	Mon Aug 15 07:34:03 2011 -0700
@@ -342,9 +342,10 @@
     std::string description = "";
 
     {
-        boost::scoped_ptr<boost::uint8_t> buf1( new boost::uint8_t[pdal::drivers::las::VariableLengthRecord::s_headerLength]);
+        // BUG: this should be a scoped ptr
+        boost::uint8_t* buf1 = new boost::uint8_t[pdal::drivers::las::VariableLengthRecord::s_headerLength];
         Utils::read_n(buf1, m_istream, pdal::drivers::las::VariableLengthRecord::s_headerLength);
-        boost::uint8_t* p1 = buf1.get();
+        boost::uint8_t* p1 = buf1;
 
         reserved = Utils::read_field<boost::uint16_t>(p1);
         boost::ignore_unused_variable_warning(reserved);
@@ -359,6 +360,8 @@
         boost::uint8_t description_data[32];
         Utils::read_array_field(p1, description_data, 32);
         description = VariableLengthRecord::bytes2string(description_data, 32);
+
+        delete[] buf1;
     }
 
     boost::uint8_t* data = new boost::uint8_t[recordLenAfterHeader];


More information about the Liblas-commits mailing list