From ee5a7c54bd32d1833fdd537db45773d4c99ea1a4 Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Sun, 8 Dec 2024 20:53:49 -0500 Subject: [PATCH 1/5] Fix Resource Leak --- lib/raster/put_title.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/raster/put_title.c b/lib/raster/put_title.c index 8d0d4f0b43f..008f767b9c3 100644 --- a/lib/raster/put_title.c +++ b/lib/raster/put_title.c @@ -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")); + remove(tempfile); return -1; } @@ -52,6 +53,7 @@ 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); return -1; } From 2c3309464d20ca71d5665c986dd0e9dbee9a845d Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Mon, 9 Dec 2024 15:10:35 -0500 Subject: [PATCH 2/5] Used G_free() --- lib/raster/put_title.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/raster/put_title.c b/lib/raster/put_title.c index 008f767b9c3..d5e45998099 100644 --- a/lib/raster/put_title.c +++ b/lib/raster/put_title.c @@ -36,6 +36,7 @@ int Rast_put_cell_title(const char *name, const char *title) fclose(in); G_warning(_("G_put_title - can't create a temp file")); remove(tempfile); + G_free(tempfile); return -1; } @@ -54,6 +55,7 @@ int Rast_put_cell_title(const char *name, const char *title) G_warning(_("category information for [%s] in [%s] invalid"), name, mapset); remove(tempfile); + G_free(tempfile); return -1; } @@ -77,6 +79,7 @@ int Rast_put_cell_title(const char *name, const char *title) fclose(in); fclose(out); remove(tempfile); + G_free(tempfile); return 1; } From 52a81e9499f5e4580f262fae0b7f95328036e426 Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Mon, 9 Dec 2024 15:33:07 -0500 Subject: [PATCH 3/5] Update Requested changes --- lib/raster/put_title.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/raster/put_title.c b/lib/raster/put_title.c index d5e45998099..ff51fc0d392 100644 --- a/lib/raster/put_title.c +++ b/lib/raster/put_title.c @@ -35,7 +35,6 @@ 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")); - remove(tempfile); G_free(tempfile); return -1; } From 32f6b0a901e3bf5fb650bdeae3f38ad032f5f385 Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Mon, 9 Dec 2024 17:24:50 -0500 Subject: [PATCH 4/5] updated changes --- lib/raster/put_title.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/raster/put_title.c b/lib/raster/put_title.c index ff51fc0d392..7caa4e2c860 100644 --- a/lib/raster/put_title.c +++ b/lib/raster/put_title.c @@ -61,6 +61,7 @@ int Rast_put_cell_title(const char *name, const char *title) in = fopen(tempfile, "r"); if (!in) { G_warning(_("G_put_title - can't reopen temp file")); + G_free(tempfile); return -1; } @@ -69,6 +70,7 @@ 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); + G_free(tempfile); return -1; } From bbe53459bfedb9f640dbcaff90c5d05563bd6ae0 Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Mon, 9 Dec 2024 17:36:03 -0500 Subject: [PATCH 5/5] updated changes --- lib/raster/put_title.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/raster/put_title.c b/lib/raster/put_title.c index 7caa4e2c860..346bf12f23d 100644 --- a/lib/raster/put_title.c +++ b/lib/raster/put_title.c @@ -70,6 +70,7 @@ 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); return -1; }