From 9ee0bfe63375a89f8c4e3a9a9e8c1a4476b38e2e Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 8 Mar 2014 16:47:06 -0800 Subject: Don't use dive before checking it against NULL Dive gets dereferenced in get_surface_pressure_in_mbar(). Signed-off-by: Dirk Hohndel --- divelist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/divelist.c b/divelist.c index 2d8918784..229ea19c8 100644 --- a/divelist.c +++ b/divelist.c @@ -388,10 +388,11 @@ double init_decompression(struct dive *dive) timestamp_t when, lasttime = 0; bool deco_init = false; double tissue_tolerance, surface_pressure; - tissue_tolerance = surface_pressure = get_surface_pressure_in_mbar(dive, true) / 1000.0; if (!dive) return 0.0; + + tissue_tolerance = surface_pressure = get_surface_pressure_in_mbar(dive, true) / 1000.0; divenr = get_divenr(dive); when = dive->when; i = divenr; -- cgit v1.2.3-70-g09d2