public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [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; 2+ 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] 2+ messages in thread

* [PATCH 2/2] newlib/doc/makedoc.c: if realloc() fails, exit with an error message.
  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 ` Joel Sherrill
  0 siblings, 0 replies; 2+ messages in thread
From: Joel Sherrill @ 2021-06-17 21:53 UTC (permalink / raw)
  To: newlib

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


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

end of thread, other threads:[~2021-06-17 21:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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).