Skip to content
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/raster: Fix Resource Leak issue in put_title.c #4821

Merged
merged 5 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/raster/put_title.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ int Rast_put_cell_title(const char *name, const char *title)
if (!out) {
fclose(in);
G_warning(_("G_put_title - can't create a temp file"));
G_free(tempfile);
return -1;
}

Expand All @@ -52,12 +53,15 @@ int Rast_put_cell_title(const char *name, const char *title)
if (line < 3) {
G_warning(_("category information for [%s] in [%s] invalid"), name,
mapset);
remove(tempfile);
G_free(tempfile);
return -1;
}

in = fopen(tempfile, "r");
if (!in) {
G_warning(_("G_put_title - can't reopen temp file"));
G_free(tempfile);
return -1;
}

Expand All @@ -66,6 +70,8 @@ int Rast_put_cell_title(const char *name, const char *title)
fclose(in);
G_warning(_("can't write category information for [%s] in [%s]"), name,
mapset);
remove(tempfile);
G_free(tempfile);
nilason marked this conversation as resolved.
Show resolved Hide resolved
return -1;
}

Expand All @@ -75,6 +81,7 @@ int Rast_put_cell_title(const char *name, const char *title)
fclose(in);
fclose(out);
remove(tempfile);
G_free(tempfile);

return 1;
}
Loading