From c373136679859e2614c40ed018458e3a8d51c0f4 Mon Sep 17 00:00:00 2001 From: Oswald Auguste de Bruin Date: Tue, 3 Sep 2013 09:53:27 +0200 Subject: [PATCH] Mem leak fixed --- lib/ogg.cpp | 6 ++++++ lib/ogg.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ogg.cpp b/lib/ogg.cpp index 43d1ded7..0592d6e9 100644 --- a/lib/ogg.cpp +++ b/lib/ogg.cpp @@ -44,6 +44,12 @@ namespace OGG{ datasize = 0; dataSum = 0; } + + Page::~Page(){ + if (data){ + free(data); + } + } bool Page::read(std::string & newData){ segmentTableDeque.clear(); diff --git a/lib/ogg.h b/lib/ogg.h index b0abcf20..368adf5b 100644 --- a/lib/ogg.h +++ b/lib/ogg.h @@ -11,6 +11,7 @@ namespace OGG{ class Page{ public: Page(); + ~Page(); bool read(std::string & newData); long unsigned int getMagicNumber(); void setMagicNumber(); @@ -49,7 +50,7 @@ namespace OGG{ private: std::deque segmentTableDeque; char* data;//pointer to the beginning of the Page data - unsigned int datasize;//size of the complete page + unsigned int datasize;//size of the allocated memory unsigned int dataSum;//size of the total segments bool checkDataSize(unsigned int size); std::string codec;//codec in the page