Skip to content

Commit

Permalink
Merge branch 'OSGeo:main' into i.emissivity_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jayneel-shah18 authored Feb 25, 2025
2 parents fd97a1b + 9b8a52a commit 09fa928
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ OBJ.*
locale/scriptstrings/*
bin.*/*
build
/out/
dist.*/*
config.log
config.status*
Expand Down Expand Up @@ -54,6 +55,9 @@ env/
# VSCode Settings
.vscode/

# Visual Studio
/.vs

# ignore gunittest helper and result files
testreport/*
testsuite/examples/testreports/
Expand Down
20 changes: 17 additions & 3 deletions lib/ogsf/gp3.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include <grass/glocale.h>
#include <grass/ogsf.h>

/*!
Free linked list of geopoint objects
*/
static void free_geopoint_list(geopoint *top);

/*!
\brief Load to points to memory
Expand Down Expand Up @@ -91,8 +96,7 @@ geopoint *Gp_load_sites(const char *name, int *nsites, int *has_z)
case -1: {
G_warning(_("Unable to read vector map <%s>"), mname);
G_free(mname);
G_free(top);
G_free(gpt);
free_geopoint_list(top);
return NULL;
}
case -2: /* EOF */
Expand Down Expand Up @@ -132,6 +136,7 @@ geopoint *Gp_load_sites(const char *name, int *nsites, int *has_z)
(geopoint *)G_malloc(sizeof(geopoint)); /* G_fatal_error */
G_zero(gpt->next, sizeof(geopoint));
if (!gpt->next) {
free_geopoint_list(top);
return NULL;
}

Expand All @@ -151,7 +156,7 @@ geopoint *Gp_load_sites(const char *name, int *nsites, int *has_z)
_("No points from vector map <%s> fall within current region"),
mname);
G_free(mname);
G_free(top);
free_geopoint_list(top);
return (NULL);
}
else {
Expand Down Expand Up @@ -309,3 +314,12 @@ int Gp_load_sites_thematic(geosite *gp, struct Colors *colors)
Vect_destroy_field_info(Fi);
return npts;
}

static void free_geopoint_list(geopoint *top)
{
while (top) {
geopoint *next = top->next;
G_free(top);
top = next;
}
}
4 changes: 3 additions & 1 deletion raster/r.kappa/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ static void layer(const char *s)
const char *mapset;
int n;

strcpy(name, s);
if (G_strlcpy(name, s, sizeof(name)) >= sizeof(name)) {
G_fatal_error(_("Raster map name <%s> is too long"), s);
}
if ((mapset = G_find_raster2(name, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), s);

Expand Down
8 changes: 6 additions & 2 deletions raster/r.kappa/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ int stats(void)
const char *argv[9];
int argc = 0;

strcpy(mname, maps[1]);
if (G_strlcpy(mname, maps[1], sizeof(mname)) >= sizeof(mname)) {
G_fatal_error(_("Raster map name <%s> is too long"), maps[1]);
}
mmapset = G_find_raster2(mname, "");
if (mmapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), maps[0]);

strcpy(rname, maps[0]);
if (G_strlcpy(rname, maps[0], sizeof(rname)) >= sizeof(rname)) {
G_fatal_error(_("Raster map name <%s> is too long"), maps[0]);
}
rmapset = G_find_raster2(rname, "");
if (rmapset == NULL)
G_fatal_error(_("Raster map <%s> not found"), maps[1]);
Expand Down

0 comments on commit 09fa928

Please sign in to comment.