From edd43e8f1d5b6b692580a27507391908a2066b25 Mon Sep 17 00:00:00 2001 From: Paul Koning Date: Mon, 27 Jun 2022 14:28:02 -0400 Subject: [PATCH] Fix .ident handling for ident strings 3 chars or less. --- assemble.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assemble.c b/assemble.c index eac35ff..21dc177 100644 --- a/assemble.c +++ b/assemble.c @@ -83,16 +83,19 @@ static unsigned * assemble_rad50 ( } while (!EOL(*cp)); wcnt = (len + 2) / 3; + /* Return at most "max" words, if specified */ if (max && max < wcnt) wcnt = max; if (count != NULL) *count = wcnt; - - ret = memcheck (malloc (wcnt * sizeof (int))); + + /* Allocate space for actual or max words, whichever is larger */ + ret = memcheck (malloc (((wcnt < max) ? max : wcnt) * sizeof (int))); for (i = 0; i < wcnt; i++) { int word = packrad50word(radstr + i * 3, len - (i * 3)); ret[i] = word; } + /* If max is specified, zero fill */ for (; i < max; i++) ret[i] = 0;