[PATCH 2/2] newlib/doc/makedoc.c: if realloc() fails, exit with an error message.

Joel Sherrill <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.