From 4866c35070869f28eca3d9398ec410512fd4d5c7 Mon Sep 17 00:00:00 2001 From: Justin Israel Date: Sat, 10 Sep 2022 09:51:26 +1200 Subject: [PATCH] cpp: fix FrameSet memory leak when getting inverted range --- CHANGES | 4 ++++ cpp/frameset.cpp | 2 -- cpp/test/TestFrameSet.cc | 13 ++++++++++++- fileseq.go | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 3c2dc15..f01309f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,9 @@ Changes: +2.11.1 +---------------- +* cpp - Fix FrameSet::inverted() memory leak + 2.11.0 ---------------- * go/cpp - Implement UDIM style syntax for padding diff --git a/cpp/frameset.cpp b/cpp/frameset.cpp index 06ce6bd..0d9bbe4 100644 --- a/cpp/frameset.cpp +++ b/cpp/frameset.cpp @@ -259,7 +259,6 @@ FrameSet FrameSet::inverted() const { m_frameData->ranges.inverted(ranges); // Create a new internal data member and swap in our ranges - newFrameSet.m_frameData = new internal::FrameSetData(); newFrameSet.m_frameData->frameRange = ranges.string(); std::swap(newFrameSet.m_frameData->ranges, ranges); @@ -295,7 +294,6 @@ FrameSet FrameSet::normalized() const { m_frameData->ranges.normalized(ranges); // Create a new internal data member and swap in our ranges - newFrameSet.m_frameData = new internal::FrameSetData(); newFrameSet.m_frameData->frameRange = ranges.string(); std::swap(newFrameSet.m_frameData->ranges, ranges); diff --git a/cpp/test/TestFrameSet.cc b/cpp/test/TestFrameSet.cc index 50d1da0..dd2785a 100644 --- a/cpp/test/TestFrameSet.cc +++ b/cpp/test/TestFrameSet.cc @@ -277,7 +277,7 @@ class TestFrameSetInverted : public testing::Test { }; -TEST_F( TestFrameSetInverted, Inverted ) { +TEST_F( TestFrameSetInverted, InvertedFrameRange ) { for (size_t i=0; i < m_cases.size(); ++i) { Case t = m_cases[i]; @@ -288,3 +288,14 @@ TEST_F( TestFrameSetInverted, Inverted ) { } }; +TEST_F( TestFrameSetInverted, Inverted ) { + for (size_t i=0; i < m_cases.size(); ++i) { + Case t = m_cases[i]; + + fileseq::FrameSet s(t.range); + auto inverted = s.inverted(); + EXPECT_EQ(t.expected, inverted.frameRange(t.zfill)) + << "Given invertedFrameRange(pad=" << t.zfill << ") on range " << t.range; + } +}; + diff --git a/fileseq.go b/fileseq.go index 17dd7a8..c23d67e 100644 --- a/fileseq.go +++ b/fileseq.go @@ -28,7 +28,7 @@ import ( "strings" ) -const Version = "2.11.0" +const Version = "2.11.1" var ( // Regular expression patterns for matching frame set strings.