[PATCH] MSP430: Fix message in sbrk.c printing binary character
Jozef Lawrynowicz
jozef.l@mittosystems.com
Thu Sep 3 13:02:23 GMT 2020
On Thu, Sep 03, 2020 at 12:14:45PM +0000, Łukasz Żak wrote:
> I would like to point out that this patch is in fact incorrect.
>
> >+ const char * const msg = "Heap and stack collision\n";
> >+ write (1, msg, sizeof (msg) - 1);
>
> As msg is pointer then sizeof(msg) will be the size of pointer and not the length of the actual string literal,
> therefore the write call will capture only the beginning of the message.
Whoops, my mistake, thanks for spotting that.
Fixed in the attached patch.
Thanks,
Jozef
>
> Regards,
> Łukasz Żak
>
-------------- next part --------------
>From 32a56f154205b179512cfab2a7523fb855898a8a Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Thu, 3 Sep 2020 14:00:32 +0100
Subject: [PATCH] MSP430: Fix calculation of string length in sbrk.c
---
libgloss/msp430/sbrk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libgloss/msp430/sbrk.c b/libgloss/msp430/sbrk.c
index 8e4339f6e..01d13b792 100644
--- a/libgloss/msp430/sbrk.c
+++ b/libgloss/msp430/sbrk.c
@@ -24,7 +24,7 @@ _sbrk (int adj)
if (heap + adj > sp)
{
- const char * const msg = "Heap and stack collision\n";
+ const char msg[] = "Heap and stack collision\n";
write (1, msg, sizeof (msg) - 1);
abort ();
}
--
2.28.0
More information about the Newlib
mailing list