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 <jlmulder@xs4all.nl>
This commit is contained in:
Jan Mulder 2018-10-31 11:22:52 +01:00 committed by Dirk Hohndel
parent 68d7e7c4e3
commit 26f6d95305

View file

@ -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);