Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/vector/Vlib: Fix Resource leak issue in geos.c #4507

Merged
merged 7 commits into from
Oct 15, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions lib/vector/Vlib/geos.c
ShubhamDesai marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,24 @@ GEOSCoordSequence *V1_read_line_geos(struct Map_info *Map, long offset,
else
z = NULL;

if (0 >= dig__fread_port_D(x, n_points, &(Map->dig_fp)))
return NULL; /* end of file */
if (0 >= dig__fread_port_D(x, n_points, &(Map->dig_fp))) {
GEOSCoordSeq_destroy(pseq);
nilason marked this conversation as resolved.
Show resolved Hide resolved
pseq = NULL;
goto free_return;
nilason marked this conversation as resolved.
Show resolved Hide resolved
}

if (0 >= dig__fread_port_D(y, n_points, &(Map->dig_fp)))
return NULL; /* end of file */
if (0 >= dig__fread_port_D(y, n_points, &(Map->dig_fp))) {
GEOSCoordSeq_destroy(pseq);
pseq = NULL;
goto free_return;
nilason marked this conversation as resolved.
Show resolved Hide resolved
}

if (Map->head.with_z) {
if (0 >= dig__fread_port_D(z, n_points, &(Map->dig_fp)))
return NULL; /* end of file */
if (0 >= dig__fread_port_D(z, n_points, &(Map->dig_fp))) {
GEOSCoordSeq_destroy(pseq);
pseq = NULL;
goto free_return;
nilason marked this conversation as resolved.
Show resolved Hide resolved
}
}

for (i = 0; i < n_points; i++) {
Expand All @@ -382,6 +391,7 @@ GEOSCoordSequence *V1_read_line_geos(struct Map_info *Map, long offset,

G_debug(3, " off = %ld", (long)dig_ftell(&(Map->dig_fp)));

free_return:
G_free((void *)x);
G_free((void *)y);
if (z)
Expand Down
Loading