Fix segfault when tripping over something
authorPasi Kallinen <paxed@alt.org>
Sun, 11 Oct 2015 18:51:01 +0000 (21:51 +0300)
committerPasi Kallinen <paxed@alt.org>
Sun, 11 Oct 2015 18:53:40 +0000 (21:53 +0300)
If you tripped over something, and there were no rocks on
that place, the otmp object variable was set to null but used
later for checking if it was a corpse.

src/timeout.c

index 44b81a5be2cc92267da05f42dc9cfde10ef3e62b..dd0a4b9aa8cf1488eda95f2e83a2ecf2ec853d73 100644 (file)
@@ -692,7 +692,7 @@ struct obj *figurine;
 STATIC_OVL void
 slip_or_trip()
 {
-    struct obj *otmp = vobj_at(u.ux, u.uy);
+    struct obj *otmp = vobj_at(u.ux, u.uy), *otmp2;
     const char *what;
     char buf[BUFSZ];
     boolean on_foot = TRUE;
@@ -716,9 +716,9 @@ slip_or_trip()
                                                              : "them")
                 : (otmp->dknown || !Blind)
                       ? doname(otmp)
-                      : ((otmp = sobj_at(ROCK, u.ux, u.uy)) == 0
+                      : ((otmp2 = sobj_at(ROCK, u.ux, u.uy)) == 0
                              ? something
-                             : (otmp->quan == 1L ? "a rock" : "some rocks"));
+                             : (otmp2->quan == 1L ? "a rock" : "some rocks"));
         if (Hallucination) {
             what = strcpy(buf, what);
             buf[0] = highc(buf[0]);