Skip to content

Fix a memory leak in set_from()#115

Open
ian-abbott wants to merge 1 commit into
corecode:masterfrom
ian-abbott:fix-memleak-in-set_from
Open

Fix a memory leak in set_from()#115
ian-abbott wants to merge 1 commit into
corecode:masterfrom
ian-abbott:fix-memleak-in-set_from

Conversation

@ian-abbott

Copy link
Copy Markdown
Contributor

Free the allocated 'sender' string when returning NULL on error.

Free the allocated 'sender' string when returning NULL on error.
@corecode

corecode commented Jan 4, 2023

Copy link
Copy Markdown
Owner

I don't think this is necessary. Failing set_from will terminate the process right after.

@emaste

emaste commented Jan 4, 2023

Copy link
Copy Markdown
Collaborator

IMO changes like this are reasonable even if only to silence potential warnings from static analysis tools.

@corecode

corecode commented Jan 4, 2023

Copy link
Copy Markdown
Owner

fair enough, but all of dma is written with this idiom. It simplifies a lot of code.

@ngie-eign

Copy link
Copy Markdown
Contributor

@corecode : could you please take this change? Something like this would mute complaints from Coverity, cppcheck, etc, even if the program dies shortly after. I realize there are tradeoffs to this, but I would think/hope that the compiler does the right thing by optimizing away the free(3) call, except when -O0 is specified.
Cheers!

@corecode

corecode commented Jun 6, 2026 via email

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants