diff options
| author | Mike Smith <msmith@FreeBSD.org> | 1999-01-24 05:58:18 +0000 |
|---|---|---|
| committer | Mike Smith <msmith@FreeBSD.org> | 1999-01-24 05:58:18 +0000 |
| commit | f7f7a5d7ab1836f66f17957e414d7765386fda5a (patch) | |
| tree | 626f11424cd7b5e8d8bb926ef4c593cef0dd03cc /sys/boot | |
| parent | 161a8f65190b457387b043e4c2ff26bc561fb758 (diff) | |
Notes
Diffstat (limited to 'sys/boot')
| -rw-r--r-- | sys/boot/ficl/words.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/sys/boot/ficl/words.c b/sys/boot/ficl/words.c index d7a420b00861a..cc0db3d83c58a 100644 --- a/sys/boot/ficl/words.c +++ b/sys/boot/ficl/words.c @@ -2755,26 +2755,22 @@ static void type(FICL_VM *pVM) { UNS32 count = stackPopUNS32(pVM->pStack); char *cp = stackPopPtr(pVM->pStack); + char *pDest = (char *)ficlMalloc(count); /* ** Since we don't have an output primitive for a counted string ** (oops), make sure the string is null terminated. If not, copy ** and terminate it. */ - /* XXX Uses free space on top of dictionary. Is it guaranteed - * XXX to always fit? (abial) - */ - if (cp[count] != '\0') - { - char *pDest = (char *)ficlGetDict()->here; - if (cp != pDest) - strncpy(pDest, cp, count); + if (!pDest) + vmThrowErr(pVM, "Error: out of memory"); - pDest[count] = '\0'; - cp = pDest; - } + strncpy(pDest, cp, count); + pDest[count] = '\0'; vmTextOut(pVM, cp, 0); + + ficlFree(pDest); return; } |
