Skip to content

Commit

Permalink
lib/raster3d: Fix Resource Leak issues in index.c (#4754)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShubhamDesai authored Dec 2, 2024
1 parent 43b9d8d commit 6d884a5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/raster3d/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static int Rast3d_readIndex(RASTER3D_Map *map)
if (indexLength == map->indexLongNbytes * map->nTiles) {
if (read(map->data_fd, tmp, indexLength) != indexLength) {
Rast3d_error("Rast3d_readIndex: can't read file");
Rast3d_free(tmp);
return 0;
}
}
Expand All @@ -52,6 +53,7 @@ static int Rast3d_readIndex(RASTER3D_Map *map)
tmp2 = Rast3d_malloc(indexLength);
if (tmp2 == NULL) {
Rast3d_error("Rast3d_readIndex: error in Rast3d_malloc");
Rast3d_free(tmp);
return 0;
}
}
Expand All @@ -60,6 +62,8 @@ static int Rast3d_readIndex(RASTER3D_Map *map)

if (read(map->data_fd, tmp2, indexLength) != indexLength) {
Rast3d_error("Rast3d_readIndex: can't read file");
Rast3d_free(tmp);
Rast3d_free(tmp2);
return 0;
}

Expand Down Expand Up @@ -117,6 +121,7 @@ int Rast3d_flush_index(RASTER3D_Map *map)
indexLength = map->nTiles * sizeof(long);
if (write(map->data_fd, tmp, indexLength) != indexLength) {
Rast3d_error("Rast3d_flush_index: can't write file");
Rast3d_free(tmp);
return 0;
}

Expand Down

0 comments on commit 6d884a5

Please sign in to comment.