-
Notifications
You must be signed in to change notification settings - Fork 2
leaky function coverity testing -- DO NOT MERGE #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -234,6 +234,16 @@ int drop_root(void) | |||||
| return retval; | ||||||
| } | ||||||
|
|
||||||
| void leaky_function(void) { | ||||||
| char *p = (char *)malloc(100); // allocated but never freed -> leak | ||||||
| if (!p) { | ||||||
| perror("malloc"); | ||||||
| return; | ||||||
| } | ||||||
| strcpy(p, "This buffer is intentionally leaked."); | ||||||
|
||||||
| strcpy(p, "This buffer is intentionally leaked."); | |
| (void)strcpy_s(p, 100, "This buffer is intentionally leaked."); |
Copilot
AI
Feb 4, 2026
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.
This entire function appears to be test code for Coverity analysis and should not be included in production code. The PR title explicitly states "DO NOT MERGE", indicating this is intentional test code that should not be merged.
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.
Coverity Issue - Resource leak
Variable "p" going out of scope leaks the storage it points to.
High Impact, CWE-404
RESOURCE_LEAK
Copilot
AI
Feb 4, 2026
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.
Calling leaky_function in main will cause a memory leak on every program execution. This function serves no purpose and should be removed.
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.
Memory leak: malloc allocates 100 bytes but the memory is never freed. This will cause a memory leak each time the function is called.