public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libc/stdlib/nano-mallocr.c, typo in variable name
@ 2023-08-28 11:02 Pekka Seppänen
  2023-08-29 12:36 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Pekka Seppänen @ 2023-08-28 11:02 UTC (permalink / raw)
  To: newlib

Hi,

Nano malloc uses `size' in assertation whereas the correct variable 
would be `s'.  Given this has existed ever since nano malloc support was 
added, based on the context ("returned payload area of desired size does 
not exceed the actual allocated chunk") I presume that indeed `s' (user 
input) and not `r->size' (computed) shall be used.

---

diff --git a/newlib/libc/stdlib/nano-mallocr.c 
b/newlib/libc/stdlib/nano-mallocr.c
index a2b50facc..41e69abb0 100644
--- a/newlib/libc/stdlib/nano-mallocr.c
+++ b/newlib/libc/stdlib/nano-mallocr.c
@@ -396,7 +396,7 @@ void * nano_malloc(RARG malloc_size_t s)
          *(long *)((char *)r + offset) = -offset;
      }

-    assert(align_ptr + size <= (char *)r + alloc_size);
+    assert(align_ptr + s <= (char *)r + alloc_size);
      return align_ptr;
  }
  #endif /* DEFINE_MALLOC */

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-29 12:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-28 11:02 [PATCH] libc/stdlib/nano-mallocr.c, typo in variable name Pekka Seppänen
2023-08-29 12:36 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).