Skip to content

Commit

Permalink
Fix Resource Leak issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham Vasudeo Desai committed Jan 15, 2025
1 parent ba3d03d commit 7f39bd5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vector/v.to.rast/do_areas.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ int sort_areas(struct Map_info *Map, struct line_pnts *Points, int field,

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

/* allocate list to hold valid area info */
list = (struct list *)G_calloc(nareas * sizeof(char), sizeof(struct list));
Expand Down Expand Up @@ -155,6 +157,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 7f39bd5

Please sign in to comment.