From a6a2e0b5daa800d9fbdeba3b877aa181a294591c Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 4 Jun 2016 17:38:25 +0200 Subject: [PATCH] subs: Oops on makelost() / makenotlost() with no owner This catches bogus entries in the "lost" file like the ones fixed in the previous commit. Signed-off-by: Markus Armbruster --- src/lib/subs/lostsub.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/subs/lostsub.c b/src/lib/subs/lostsub.c index ad423c25..b2505438 100644 --- a/src/lib/subs/lostsub.c +++ b/src/lib/subs/lostsub.c @@ -28,7 +28,7 @@ * * Known contributors to this file: * Steve McClure, 1997 - * Markus Armbruster, 2008 + * Markus Armbruster, 2008-2016 */ #include @@ -60,6 +60,8 @@ makelost(int type, natid owner, int id, coord x, coord y) struct loststr lost; int n; + if (CANT_HAPPEN(!owner)) + return; n = findlost(type, owner, id, x, y, 1); ef_blank(EF_LOST, n, &lost); lost.lost_type = type; @@ -76,6 +78,8 @@ makenotlost(int type, natid owner, int id, coord x, coord y) struct loststr lost; int n; + if (CANT_HAPPEN(!owner)) + return; n = findlost(type, owner, id, x, y, 0); if (n < 0) return;