htrdr

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

commit 327bd21a0ed14ae6dfc44f4cd87b395624dfff07
parent 528f9f0edee8eba6eaed62066fa201e3863d8468
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 11 May 2023 11:05:28 +0200

Update error handling in htrdr_ran_wlen_planck_create

In an error occurs, the function would simply free the created structure
without assigning NULL to the returned pointer. As a result, the caller
could think that the structure was still allocated and try to free it,
leading to a double freeing of memory and thus a crash. In this commit,
we correct this problem by simply returning a NULL pointer when an error
has been detected by the function.

Diffstat:
Msrc/core/htrdr_ran_wlen_planck.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/core/htrdr_ran_wlen_planck.c b/src/core/htrdr_ran_wlen_planck.c @@ -335,7 +335,10 @@ exit: *out_wlen_planck_ran = planck; return res; error: - if(planck) htrdr_ran_wlen_planck_ref_put(planck); + if(planck) { + htrdr_ran_wlen_planck_ref_put(planck); + planck = NULL; + } goto exit; }