public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* makedoc.c: Coverity Scan Issues
@ 2021-06-17 18:06 Joel Sherrill
       [not found] ` <BN3P110MB05635FBA2AA46EEA2E677F7D9A0E9@BN3P110MB0563.NAMP110.PROD.OUTLOOK.COM>
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Sherrill @ 2021-06-17 18:06 UTC (permalink / raw)
  To: Newlib

Hi

Scan reports 3 issues in makedoc.c.

  One  is a memory leak around lines 1202 to 1282 because the variable word
holds memory allocated inside nextword. The method returns without freeing
the memory.    I think adding a free() is sufficient for this.

The others are from calling realloc() and not checking for NULL around line
137. Is checking for the NULL, printing a message, and exit(1), an OK thing
to do here?

Thanks.

--joel

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

* Re: Fw: makedoc.c: Coverity Scan Issues
       [not found] ` <BN3P110MB05635FBA2AA46EEA2E677F7D9A0E9@BN3P110MB0563.NAMP110.PROD.OUTLOOK.COM>
@ 2021-06-17 18:28   ` C Howland
  2021-06-17 18:36     ` Joel Sherrill
  0 siblings, 1 reply; 3+ messages in thread
From: C Howland @ 2021-06-17 18:28 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 2:06 PM
> *To:* Newlib <newlib@sourceware.org>
> *Subject:* makedoc.c: Coverity Scan Issues
>
>
> Hi
>
> Scan reports 3 issues in makedoc.c.
>
>   One  is a memory leak around lines 1202 to 1282 because the variable word
> holds memory allocated inside nextword. The method returns without freeing
> the memory.    I think adding a free() is sufficient for this.
>
> The others are from calling realloc() and not checking for NULL around line
> 137. Is checking for the NULL, printing a message, and exit(1), an OK thing
> to do here?
>
> Yes, that sounds good.  (Seems very unlikely it would ever happen, anyway.)
Craig

> Thanks.
>
> --joel
>
>
>

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

* Re: Fw: makedoc.c: Coverity Scan Issues
  2021-06-17 18:28   ` Fw: " C Howland
@ 2021-06-17 18:36     ` Joel Sherrill
  0 siblings, 0 replies; 3+ messages in thread
From: Joel Sherrill @ 2021-06-17 18:36 UTC (permalink / raw)
  To: C Howland; +Cc: Newlib

On Thu, Jun 17, 2021 at 1:30 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 2:06 PM
> > *To:* Newlib <newlib@sourceware.org>
> > *Subject:* makedoc.c: Coverity Scan Issues
> >
> >
> > Hi
> >
> > Scan reports 3 issues in makedoc.c.
> >
> >   One  is a memory leak around lines 1202 to 1282 because the variable
> word
> > holds memory allocated inside nextword. The method returns without
> freeing
> > the memory.    I think adding a free() is sufficient for this.
> >
> > The others are from calling realloc() and not checking for NULL around
> line
> > 137. Is checking for the NULL, printing a message, and exit(1), an OK
> thing
> > to do here?
> >
> > Yes, that sounds good.  (Seems very unlikely it would ever happen,
> anyway.)
>

I agree since this is one of the few host based utilities in newlib. But it
seemed
better to address it.

I'll try to post patches shortly.

FWIW there are 61 defects being reported right now for newlib. I'm building
for sparc-rtems6 as we use leon3 as our reference BSP for RTEMS coverity.
It checks a few times a day if the RTEMS newlib git mirror has been updated
and then kicks off an analysis. Happy to share the issues if anyone cares.

--joel


> Craig
>
> > Thanks.
> >
> > --joel
> >
> >
> >
>

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 18:06 makedoc.c: Coverity Scan Issues Joel Sherrill
     [not found] ` <BN3P110MB05635FBA2AA46EEA2E677F7D9A0E9@BN3P110MB0563.NAMP110.PROD.OUTLOOK.COM>
2021-06-17 18:28   ` Fw: " C Howland
2021-06-17 18:36     ` 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).