From 26f6d95305acdb86c99e11c017987497d0238321 Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Wed, 31 Oct 2018 11:22:52 +0100 Subject: Core: Do not crash on save dives with no dive site (git storage) And fix a crash very similar to the previous commit. When trying to save (to git) with an empty dive site, ssrf crashes. Again, add a simple guard to prevent this. Signed-off-by: Jan Mulder --- core/save-git.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core/save-git.c') diff --git a/core/save-git.c b/core/save-git.c index 413c66211..422201324 100644 --- a/core/save-git.c +++ b/core/save-git.c @@ -431,7 +431,8 @@ static void create_dive_buffer(struct dive *dive, struct membuffer *b) SAVE("visibility", visibility); cond_put_format(dive->tripflag == NO_TRIP, b, "notrip\n"); save_tags(b, dive->tag_list); - cond_put_format(!!dive->dive_site, b, "divesiteid %08x\n", dive->dive_site->uuid); + if (dive->dive_site) + put_format(b, "divesiteid %08x\n", dive->dive_site->uuid); if (verbose && dive->dive_site) fprintf(stderr, "removed reference to non-existant dive site with uuid %08x\n", dive->dive_site->uuid); save_overview(b, dive); -- cgit v1.2.3-70-g09d2