From 39da4a1bbd0ef947d4cacdd6d94176add55f1461 Mon Sep 17 00:00:00 2001 From: monkeyman_67156 Date: Sat, 17 Oct 2009 16:24:50 +0000 Subject: fixed: memleak in texture writer, pass string by reference. git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@23797 568bbfeb-2a22-0410-94d2-cc84cf5bfa90 --- tools/TexturePacker/XBTFWriter.cpp | 5 +++-- tools/TexturePacker/XBTFWriter.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/TexturePacker/XBTFWriter.cpp b/tools/TexturePacker/XBTFWriter.cpp index ed9d784cb8..6812d8af38 100644 --- a/tools/TexturePacker/XBTFWriter.cpp +++ b/tools/TexturePacker/XBTFWriter.cpp @@ -10,10 +10,10 @@ #define WRITE_U32(i, file) { uint32_t _n = Endian_SwapLE32(i); fwrite(&_n, 4, 1, file); } #define WRITE_U64(i, file) { uint64_t _n = i; _n = Endian_SwapLE64(i); fwrite(&_n, 8, 1, file); } -CXBTFWriter::CXBTFWriter(CXBTF& xbtf, const std::string outputFile) : m_xbtf(xbtf) +CXBTFWriter::CXBTFWriter(CXBTF& xbtf, const std::string& outputFile) : m_xbtf(xbtf) { m_outputFile = outputFile; - m_file = NULL; + m_file = m_tempFile = NULL; } bool CXBTFWriter::Create() @@ -53,6 +53,7 @@ bool CXBTFWriter::Close() { fwrite(tmp, bytesRead, 1, m_file); } + delete[] tmp; fclose(m_file); fclose(m_tempFile); diff --git a/tools/TexturePacker/XBTFWriter.h b/tools/TexturePacker/XBTFWriter.h index 806c468ee6..89ac46d3bf 100644 --- a/tools/TexturePacker/XBTFWriter.h +++ b/tools/TexturePacker/XBTFWriter.h @@ -8,7 +8,7 @@ class CXBTFWriter { public: - CXBTFWriter(CXBTF& xbtf, const std::string outputFile); + CXBTFWriter(CXBTF& xbtf, const std::string& outputFile); bool Create(); bool Close(); bool AppendContent(unsigned char const* data, size_t length); -- cgit v1.2.3