From 78607a37a523e299d0d608243a992adab9120715 Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 16 Aug 2023 18:16:11 -0700 Subject: [PATCH] more obufs - two-handed weapon in "hands" Pointed out by entrez: prevent doname() from consuming two obuf[] buffers when it constructs the plural of "hand" while formatting a wielded two-handed weapon. Since only one such item should be able to occur in any list of objects, it is not likely to be the cause of any message oddities that might happen when a cached value is in a formatting buffer gets re-used too soon. However, not releasing a second buffer right away prevents an attempt to release the first one from succeeding because it won't be the last one allocated anymore, so some buffer churn was happening. --- src/objnam.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/objnam.c b/src/objnam.c index 8421c3c1f..f63f0ee1c 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1394,9 +1394,12 @@ doname_base( Strcat(bp, " (wielded)"); } else { const char *hand_s = body_part(HAND); + char *obufp, handsbuf[40]; - if (bimanual(obj)) - hand_s = makeplural(hand_s); + if (bimanual(obj)) { + hand_s = strcpy(handsbuf, obufp = makeplural(hand_s)); + releaseobuf(obufp); + } /* note: Sting's glow message, if added, will insert text in front of "(weapon in hand)"'s closing paren */ Sprintf(eos(bp), " (%s%s in %s%s)",