Skip to content

Commit

Permalink
lib/vector/Vlib: fix segfault introduced with OSGeo#5038 (OSGeo#5109)
Browse files Browse the repository at this point in the history
  • Loading branch information
metzm authored Feb 13, 2025
1 parent 442bd61 commit 3913be0
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lib/vector/Vlib/net_build.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ int Vect_net_ttb_build_graph(struct Map_info *Map, int ltype, int afield,
dglGraph_s *gr;
dglInt32_t opaqueset[16] = {360000, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0};
struct field_info *Fi;
struct field_info *Fi = NULL;
dbDriver *driver = NULL;
dbDriver *ttbdriver = NULL;
dbHandle handle;
dbString stmt;
dbColumn *Column;
dbColumn *Column = NULL;
dbCatValArray fvarr, bvarr;
int fctype = 0, bctype = 0, nrec, nturns;

Expand Down Expand Up @@ -666,8 +666,13 @@ int Vect_net_ttb_build_graph(struct Map_info *Map, int ltype, int afield,
dglInitializeSPCache(gr, &(Map->dgraph.spCache));

G_message(_("Graph was built"));
Vect_destroy_field_info(Fi);
db_free_column(Column);
if (Fi) {
Vect_destroy_field_info(Fi);
}
if (Column) {
db_free_column(Column);
}

return 0;
}

Expand Down Expand Up @@ -709,11 +714,11 @@ int Vect_net_build_graph(struct Map_info *Map, int ltype, int afield,
dglInt32_t dgl_cost;
dglInt32_t opaqueset[16] = {360000, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0};
struct field_info *Fi;
struct field_info *Fi = NULL;
dbDriver *driver = NULL;
dbHandle handle;
dbString stmt;
dbColumn *Column;
dbColumn *Column = NULL;
dbCatValArray fvarr, bvarr;
int fctype = 0, bctype = 0, nrec;

Expand Down Expand Up @@ -1063,8 +1068,12 @@ int Vect_net_build_graph(struct Map_info *Map, int ltype, int afield,
dglInitializeSPCache(gr, &(Map->dgraph.spCache));

G_message(_("Graph was built"));
Vect_destroy_field_info(Fi);
db_free_column(Column);
if (Fi) {
Vect_destroy_field_info(Fi);
}
if (Column) {
db_free_column(Column);
}

return 0;
}

0 comments on commit 3913be0

Please sign in to comment.