Skip to content

Commit

Permalink
cpp: fix FrameSet memory leak when getting inverted range
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfx committed Sep 9, 2022
1 parent 5a16561 commit 4866c35
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions cpp/frameset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
13 changes: 12 additions & 1 deletion cpp/test/TestFrameSet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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;
}
};

2 changes: 1 addition & 1 deletion fileseq.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 4866c35

Please sign in to comment.