-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
695dc53
commit 5c19ba4
Showing
1 changed file
with
5 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5c19ba4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Your fix will delete old data. There is no need to free because realloc will take care of that.
5c19ba4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I think it is still dangerous because 'm_Data = (unsigned char*)realloc(m_Data, m_Capacity);' uses 'm_Data ' as function parameter & it's result. so, when it fails, we will lose the memory of original 'm_Data'.
I hope this will help you.
https://stackoverflow.com/questions/9071566/is-it-safe-to-use-realloc
Sorry for no background DLMS/COSEM and this source ( I am currently learning it ) but, if preserving old data is important, I suggest that keep 'm_Data' until 'realloc()' is resulted safely and then copy the result into 'm_Data'.
5c19ba4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
We'll change this to work in the same way as ANSI C version.