Skip to content

Commit

Permalink
raster3d: Initialize Cell_head structure contents before using it
Browse files Browse the repository at this point in the history
If a structure is not initialized, it may contain random data. Avoid
that by initializing it.

This was found using cppcheck tool.

Signed-off-by: Mohan Yelugoti <ymdatta.work@gmail.com>
  • Loading branch information
ymdatta committed Sep 25, 2024
1 parent 0c1e79b commit a91589a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions raster3d/r3.in.lidar/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,30 @@ void binning_add_point(struct PointBinning3D *binning, int row, int col,
}
}

static void cell_head_init(struct Cell_head *region)
{
region->format = -1;
region->compressed = 0;
region->rows = 0;
region->rows3 = 0;
region->cols = 0;
region->cols3 = 0;
region->depths = 0;
region->proj = 0;
region->zone = 0;
region->ew_res = 0.0;
region->ew_res3 = 0.0;
region->ns_res = 0.0;
region->ns_res3 = 0.0;
region->tb_res = 0.0;
region->north = 0.0;
region->south = 0.0;
region->east = 0.0;
region->west = 0.0;
region->top = 0.0;
region->bottom = 0.0;
}

int main(int argc, char *argv[])
{
struct GModule *module;
Expand Down Expand Up @@ -364,10 +388,12 @@ int main(int argc, char *argv[])
struct Cell_head current_region;
struct Cell_head file_region;

cell_head_init(&file_region);
G_get_set_window(&current_region);

/* extent for all data */
struct Cell_head data_region;
cell_head_init(&data_region);

long unsigned header_count = 0;
int i;
Expand Down

0 comments on commit a91589a

Please sign in to comment.