public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: newlib@sourceware.org
Subject: Re: [PATCH 1/1] Fix null-pointer dereference in nano-malloc
Date: Wed, 26 Jan 2022 13:14:29 +0100	[thread overview]
Message-ID: <YfE7JYxG7RQ4hsrr@calimero.vinschen.de> (raw)
In-Reply-To: <20220125154410.56045-2-yaredcyril@gmail.com>

On Jan 25 07:44, Cyril Yared wrote:
> If p is NULL, then the free_list is empty and we should return the
> correct failure values.
> ---
>  newlib/libc/stdlib/nano-mallocr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/newlib/libc/stdlib/nano-mallocr.c b/newlib/libc/stdlib/nano-mallocr.c
> index 6fb08a616..0c5fb2885 100644
> --- a/newlib/libc/stdlib/nano-mallocr.c
> +++ b/newlib/libc/stdlib/nano-mallocr.c
> @@ -322,7 +322,7 @@ void * nano_malloc(RARG malloc_size_t s)
>                  r=r->next;
>              }
>  
> -            if ((char *)p + p->size == (char *)_SBRK_R(RCALL 0))
> +            if (p != NULL && (char *)p + p->size == (char *)_SBRK_R(RCALL 0))
>              {
>                 /* The last free item has the heap end as neighbour.
>                  * Let's ask for a smaller amount and merge */
> -- 
> 2.21.0 (Apple Git-122.2)

Pushed.


Thanks,
Corinna


      reply	other threads:[~2022-01-26 12:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25 15:44 [PATCH 0/1] " Cyril Yared
2022-01-25 15:44 ` [PATCH 1/1] " Cyril Yared
2022-01-26 12:14   ` Corinna Vinschen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YfE7JYxG7RQ4hsrr@calimero.vinschen.de \
    --to=vinschen@redhat.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).