Skip to content

Commit

Permalink
v.to.rast: Fix Resource Leak issue in do_areas.c (#4957)
Browse files Browse the repository at this point in the history
* Fix Resource Leak issue

* Suggested changes
  • Loading branch information
ShubhamDesai authored Jan 16, 2025
1 parent a62ee2a commit 8e575c2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vector/v.to.rast/do_areas.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,14 @@ int sort_areas(struct Map_info *Map, struct line_pnts *Points, int field,
CELL cat;

G_begin_polygon_area_calculations();
Cats = Vect_new_cats_struct();

/* first count valid areas */
nareas = Vect_get_num_areas(Map);
if (nareas == 0)
return 0;

Cats = Vect_new_cats_struct();

/* allocate list to hold valid area info */
list = (struct list *)G_calloc(nareas * sizeof(char), sizeof(struct list));

Expand Down Expand Up @@ -155,6 +156,7 @@ int sort_areas(struct Map_info *Map, struct line_pnts *Points, int field,
/* sort the list by size */
qsort(list, nareas * sizeof(char), sizeof(struct list), compare);
}
Vect_destroy_cats_struct(Cats);

return nareas_selected;
}
Expand Down

0 comments on commit 8e575c2

Please sign in to comment.