From: Joel Sherrill <joel@rtems.org>
To: C Howland <cc1964t@gmail.com>
Cc: Newlib <newlib@sourceware.org>
Subject: Re: [PATCH 2/2] newlib/doc/makedoc.c: if realloc() fails, exit with an error message.
Date: Thu, 17 Jun 2021 19:52:40 -0500 [thread overview]
Message-ID: <CAF9ehCVU-if12wPQX7V4bX5mwTC=MZtxRYAj4f6ggjnM1_CSsQ@mail.gmail.com> (raw)
In-Reply-To: <CANk6obT=7OpdavfHvh-09yUb2qOkTrUWT-ssEJURNdRnh8MSag@mail.gmail.com>
I see you replied but I don't see a comment.
On Thu, Jun 17, 2021, 6:33 PM C Howland <cc1964t@gmail.com> wrote:
> > ------------------------------
> > *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.
>
next prev parent reply other threads:[~2021-06-18 0:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-17 23:32 C Howland
2021-06-18 0:52 ` Joel Sherrill [this message]
-- 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
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='CAF9ehCVU-if12wPQX7V4bX5mwTC=MZtxRYAj4f6ggjnM1_CSsQ@mail.gmail.com' \
--to=joel@rtems.org \
--cc=cc1964t@gmail.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).