Skip to content

Commit

Permalink
v.in.dxf: Fix Resource Leak issue in read_dxf.c (#5012)
Browse files Browse the repository at this point in the history
* fix Resource Leak issue

* Update vector/v.in.dxf/read_dxf.c
  • Loading branch information
ShubhamDesai authored Jan 31, 2025
1 parent 381433a commit be75a1d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions vector/v.in.dxf/read_dxf.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ struct dxf_file *dxf_open(char *file)
struct dxf_file *dxf;

dxf = (struct dxf_file *)G_malloc(sizeof(struct dxf_file));
if (!dxf)
return NULL;

dxf->name = G_store(file);
if (!(dxf->fp = fopen(file, "r")))
if (!dxf->name) {
G_free(dxf);
return NULL;

}
if (!(dxf->fp = fopen(file, "r"))) {
G_free(dxf->name);
G_free(dxf);
return NULL;
}
/* get the file size */
G_fseek(dxf->fp, 0L, SEEK_END);
dxf->size = G_ftell(dxf->fp);
Expand Down

0 comments on commit be75a1d

Please sign in to comment.