-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add all bugs #3
base: master
Are you sure you want to change the base?
Add all bugs #3
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 |
---|---|---|
|
@@ -32,6 +32,45 @@ void print_point(struct POINT *pnt) | |
get_x(pnt), get_y(pnt)); | ||
} | ||
|
||
int resource_leak() | ||
{ | ||
FILE *fp=fopen("c:\\some\file", "r"); | ||
|
||
if (fp == NULL) { | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int memory_leak() | ||
{ | ||
struct POINT *p = malloc(sizeof(struct POINT)); | ||
|
||
if (p == NULL) { | ||
return (-2); | ||
} | ||
|
||
return -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MEMORY_LEAK: memory dynamically allocated to |
||
} | ||
|
||
void dead_store(struct POINT *pnt) | ||
{ | ||
int new_x = 9; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DEAD_STORE: The value written to &new_x (type int) is never used. |
||
new_x = get_y(pnt); | ||
set_x(pnt, new_x); | ||
} | ||
|
||
int null_dereference() | ||
{ | ||
struct POINT *p = malloc(sizeof(struct POINT)); | ||
|
||
get_x(p); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NULL_DEREFERENCE: pointer |
||
free(p); | ||
|
||
return 0; | ||
} | ||
|
||
int main(void) | ||
{ | ||
struct POINT *pnt = malloc(sizeof(struct POINT)); | ||
|
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.
RESOURCE_LEAK: resource of type
_IO_FILE
acquired toreturn
by call tofopen()
at line 37, column 14 is not released after line 43, column 5.