From f1a5de16d94fe46176a8c11e778432d65f93de3e Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 14 Apr 2015 08:55:43 +0300 Subject: [PATCH] Guard against merge segfaults Trying to throw a quivered object resulted in a segfault, when the code tried to merge the quivered object into itself. --- src/invent.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/invent.c b/src/invent.c index 9e4041603..c66129cf0 100644 --- a/src/invent.c +++ b/src/invent.c @@ -2540,6 +2540,7 @@ mergable(otmp, obj) /* returns TRUE if obj & otmp can be merged */ register struct obj *otmp, *obj; { int objnamelth = 0, otmpnamelth = 0; + if (obj == otmp) return FALSE; /* already the same object */ if (obj->otyp != otmp->otyp) return FALSE; /* coins of the same kind will always merge */ if (obj->oclass == COIN_CLASS) return TRUE;