]> granicus.if.org Git - nethack/commitdiff
doname() bookkeeping
authorPatR <rankin@nethack.org>
Tue, 26 Sep 2017 00:17:06 +0000 (17:17 -0700)
committerPatR <rankin@nethack.org>
Tue, 26 Sep 2017 00:17:06 +0000 (17:17 -0700)
doname() for a corpse was using two obufs instead of just one.

src/objnam.c

index ec7c0e70ec4f04b36d5a7ebec02b396b255e3189..5daead6477f916bbca3daa04280094868a1adf42 100644 (file)
@@ -1106,8 +1106,11 @@ unsigned doname_flags;
                "corpse" is already in the buffer returned by xname() */
             unsigned cxarg = (((obj->quan != 1L) ? 0 : CXN_ARTICLE)
                               | CXN_NOCORPSE);
+            char *cxstr = corpse_xname(obj, prefix, cxarg);
 
-            Sprintf(prefix, "%s ", corpse_xname(obj, prefix, cxarg));
+            Sprintf(prefix, "%s ", cxstr);
+            /* avoid having doname(corpse) consume an extra obuf */
+            releaseobuf(cxstr);
         } else if (obj->otyp == EGG) {
 #if 0 /* corpses don't tell if they're stale either */
             if (known && stale_egg(obj))