From b40c8769f2e4fb589de2263b7d8088d0c69ae6e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 09:34:16 +0200 Subject: Merging upstream version 1:0.1.9998svn3604+dfsg. Signed-off-by: Daniel Baumann --- src/kash/expand.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/kash') diff --git a/src/kash/expand.c b/src/kash/expand.c index ff30455..1131865 100644 --- a/src/kash/expand.c +++ b/src/kash/expand.c @@ -1555,15 +1555,15 @@ STATIC char * cvtnum(shinstance *psh, int num, char *buf) { char temp[32]; + char *p = &temp[sizeof(temp) - 1]; int neg = num < 0; - char *p = temp + 31; - - temp[31] = '\0'; + if (neg) + num = -num; + *p = '\0'; do { *--p = num % 10 + '0'; } while ((num /= 10) != 0); - if (neg) *--p = '-'; @@ -1576,11 +1576,12 @@ STATIC char * cvtnum64(shinstance *psh, KI64 num, char *buf) { char temp[32]; + char *p = &temp[sizeof(temp) - 1]; int neg = num < 0; - char *p = temp + 31; - - temp[31] = '\0'; + if (neg) + num = -num; + *p = '\0'; do { *--p = num % 10 + '0'; } while ((num /= 10) != 0); -- cgit v1.2.3