htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit f5b5aa7d0494165fd3690c24b4a8b68a07f91366
parent f0eef338c12c2ec584dfac1992257c0e1e646d7d
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed,  3 Oct 2018 11:06:08 +0200

Fix error handling of the grid creation/opening

Diffstat:
Msrc/htrdr_grid.c | 3+++
Msrc/htrdr_sky.c | 2++
2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/htrdr_grid.c b/src/htrdr_grid.c @@ -179,9 +179,11 @@ htrdr_grid_create /* Map the grid data */ grid->data = mmap(NULL, grid->data_sz, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_POPULATE, fileno(grid->fp), grid_offset); + if(grid->data == MAP_FAILED) { htrdr_log_err(htrdr, "%s:%s: could not map the grid data -- %s.\n", FUNC_NAME, filename, strerror(errno)); + grid->data = NULL; res = RES_IO_ERR; goto error; } @@ -291,6 +293,7 @@ htrdr_grid_open if(grid->data == MAP_FAILED) { htrdr_log_err(htrdr, "%s:%s: could not map the grid data -- %s.\n", FUNC_NAME, filename, strerror(errno)); + grid->data = NULL; res = RES_IO_ERR; goto error; } diff --git a/src/htrdr_sky.c b/src/htrdr_sky.c @@ -366,6 +366,7 @@ clean_clouds(struct htrdr_sky* sky) MEM_RM(sky->htrdr->allocator, sky->clouds[i]); } MEM_RM(sky->htrdr->allocator, sky->clouds); + sky->clouds = NULL; } static void @@ -397,6 +398,7 @@ clean_atmosphere(struct htrdr_sky* sky) MEM_RM(sky->htrdr->allocator, sky->atmosphere[i]); } MEM_RM(sky->htrdr->allocator, sky->atmosphere); + sky->atmosphere = NULL; } static void