Skip to content

Commit

Permalink
lib/bitmap: Fix a potential memory leak (#3004)
Browse files Browse the repository at this point in the history
map is initinialized but not free'd

Co-authored-by: Loïc Bartoletti <lbartoletti@qgis_dev.Oslandia.com>
  • Loading branch information
2 people authored and neteler committed Aug 16, 2023
1 parent e353c3c commit f51ceee
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/bitmap/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,11 @@ struct BM *BM_file_read(FILE *fp)
if (NULL == (map = (struct BM *)malloc(sizeof(struct BM))))
return (NULL);

if (fread(&c, sizeof(char), sizeof(char), fp) != sizeof(char))
if (fread(&c, sizeof(char), sizeof(char), fp) != sizeof(char)) {
free(map);
return NULL;
}

if (c != BM_MAGIC) {
free(map);
return NULL;
Expand Down

0 comments on commit f51ceee

Please sign in to comment.