Skip to content

Commit

Permalink
Merge pull request #3 from ConstantRobotics-Ltd/test-memory-leak
Browse files Browse the repository at this point in the history
Solve memory leakage in assignment operator
  • Loading branch information
ConstantRobotics authored Dec 14, 2023
2 parents 0a3b2aa + 4801d39 commit 2e0124b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 36 deletions.
Binary file not shown.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# **Frame C++ class**

**v5.0.5**
**v5.0.6**



Expand Down Expand Up @@ -52,6 +52,7 @@ Frame class is basic class for other projects. Main file **Frame.h** contains de
| 5.0.3 | 22.06.2023 | - Added build guide. |
| 5.0.4 | 06.07.2023 | - Documentation updated. |
| 5.0.5 | 12.11.2023 | - Fixed errors serialization/deserialization functions. |
| 5.0.6 | 14.12.2023 | - Memory leakage from "=" operator fixed. |



Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.13)
## LIBRARY-PROJECT
## name and version
################################################################################
project(Frame VERSION 5.0.4 LANGUAGES CXX)
project(Frame VERSION 5.0.6 LANGUAGES CXX)



Expand Down
4 changes: 4 additions & 0 deletions src/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ Frame::Frame(uint32_t _width,

Frame::Frame(Frame &src)
{
// free memory if allocated before.
release();

// Copy fields.
width = src.width;
height = src.height;
Expand Down Expand Up @@ -223,6 +226,7 @@ Frame &Frame::operator= (const Frame &src)
{
data = new uint8_t[size];
memset(data, 0, size);
m_isAllocated = true;
}

// Copy data.
Expand Down
4 changes: 2 additions & 2 deletions src/FrameVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

#define FRAME_MAJOR_VERSION 5
#define FRAME_MINOR_VERSION 0
#define FRAME_PATCH_VERSION 4
#define FRAME_PATCH_VERSION 6

#define FRAME_VERSION "5.0.4"
#define FRAME_VERSION "5.0.6"
34 changes: 2 additions & 32 deletions test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int main(void)
else
cout << "OK" << endl << endl;

return -1;
return 1;
}


Expand Down Expand Up @@ -511,34 +511,4 @@ bool serializationTest()
}

return true;
}






























}

0 comments on commit 2e0124b

Please sign in to comment.