public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Re: [PATCH 2/2] newlib/doc/makedoc.c: if realloc() fails, exit with an error message.
@ 2021-06-17 23:32 C Howland
  2021-06-18  0:52 ` Joel Sherrill
  0 siblings, 1 reply; 3+ messages in thread
From: C Howland @ 2021-06-17 23:32 UTC (permalink / raw)
  To: newlib

> ------------------------------
> *From:* Newlib <newlib-bounces+craig.howland=caci.com@sourceware.org> on
> behalf of Joel Sherrill <joel@rtems.org>
> *Sent:* Thursday, June 17, 2021 5:53 PM
> *To:* newlib@sourceware.org <newlib@sourceware.org>
> *Subject:* [PATCH 2/2] newlib/doc/makedoc.c: if realloc() fails, exit
> with an error message.
>
>
> ---
>  newlib/doc/makedoc.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/newlib/doc/makedoc.c b/newlib/doc/makedoc.c
> index 966349c51..81aa6f941 100644
> --- a/newlib/doc/makedoc.c
> +++ b/newlib/doc/makedoc.c
> @@ -135,6 +135,11 @@ catchar (string_type *buffer, char ch)
>    {
>      buffer->size *=2;
>      buffer->ptr = realloc(buffer->ptr, buffer->size);
> +    if (!buffer->ptr)
> +    {
> +      fprintf(stderr,"Can't allocate memory\n");
> +      exit(1);
> +    }
>    }
>
>    buffer->ptr[buffer->write_idx ++ ] = ch;
> --
> 2.24.4
>
> Both patches look sane.

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [PATCH 1/2] newlib/doc/makedoc.c: Fix memory leak identified by Coverity.
@ 2021-06-17 21:53 Joel Sherrill
  2021-06-17 21:53 ` [PATCH 2/2] newlib/doc/makedoc.c: if realloc() fails, exit with an error message Joel Sherrill
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Sherrill @ 2021-06-17 21:53 UTC (permalink / raw)
  To: newlib

---
 newlib/doc/makedoc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/newlib/doc/makedoc.c b/newlib/doc/makedoc.c
index 36a14e535..966349c51 100644
--- a/newlib/doc/makedoc.c
+++ b/newlib/doc/makedoc.c
@@ -1278,7 +1278,8 @@ compile (char *string)
 	}	    
     }
 
-return(ret);
+    free(word);
+    return(ret);
 }
 
  
-- 
2.24.4


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

end of thread, other threads:[~2021-06-18  0:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 23:32 [PATCH 2/2] newlib/doc/makedoc.c: if realloc() fails, exit with an error message C Howland
2021-06-18  0:52 ` Joel Sherrill
  -- strict thread matches above, loose matches on Subject: below --
2021-06-17 21:53 [PATCH 1/2] newlib/doc/makedoc.c: Fix memory leak identified by Coverity Joel Sherrill
2021-06-17 21:53 ` [PATCH 2/2] newlib/doc/makedoc.c: if realloc() fails, exit with an error message Joel Sherrill

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).