-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
lib/vector/Vlib: Fix Resource Leak issue in break_polygons.c #4612
base: main
Are you sure you want to change the base?
Conversation
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.
Some suggestions.
And please address CID 1207831 too with this PR.
if (fd < 0) { | ||
G_free(filename); | ||
G_fatal_error(_("Failed to create temporary file: %s"), | ||
strerror(errno)); | ||
} |
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.
if (fd < 0) { | |
G_free(filename); | |
G_fatal_error(_("Failed to create temporary file: %s"), | |
strerror(errno)); | |
} |
Actually, RTreeCreateTree creates in-memory RTree if open() fails. So, no error if it fails.
RTreeDestroyTree(RTree); | ||
close(fd); | ||
G_free(filename); |
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.
RTreeDestroyTree(RTree); | |
close(fd); | |
G_free(filename); | |
close(RTree->fd); |
No need to free in-memory objects in case of G_fatal_error, the system will take care of it.
if (remove(filename) != 0) { | ||
G_warning(_("Failed to remove temporary file: %s"), filename); | ||
} |
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.
if (remove(filename) != 0) { | |
G_warning(_("Failed to remove temporary file: %s"), filename); | |
} | |
(void)remove(filename); |
As the above open may fail, this may too.
This pull request fixes issue identified by Coverity scan (CID: 1207832).
Changes Made: