Re: Missing checks when malloc returns NULL... - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject Re: Missing checks when malloc returns NULL...
Date
Msg-id 20160829141315.GB8340@e733
Whole thread Raw
In response to Re: Missing checks when malloc returns NULL...  (Aleksander Alekseev <a.alekseev@postgrespro.ru>)
Responses Re: Missing checks when malloc returns NULL...  (Michael Paquier <michael.paquier@gmail.com>)
List pgsql-hackers
> Hello, Michael
>
> > I don't know how you did it, but this email has visibly broken the
> > original thread. Did you change the topic name?
>
> I'm very sorry for this. I had no local copy of this thread. So I wrote a
> new email with the same subject hoping it will be OK. Apparently right
> In-Reply-To header is also required.
>
> >   if (prodesc->user_proname == NULL || prodesc->internal_proname == NULL)
> > + {
> > +    free(prodesc);
>
> I think that prodesc->user_proname and prodesc->internal_proname should
> also be freed if they are not NULL's.
>
> > By the way maybe someone knows other procedures besides malloc, realloc
> > and strdup that require special attention?
>
> I recalled that there is also calloc(). I've found four places that use
> calloc() and look suspicious to me (see attachment). What do you think -
> are these bugs or not?

I've just realized that there is also malloc-compatible ShmemAlloc().
Apparently it's return value sometimes is not properly checked too. See
attachment.

--
Best regards,
Aleksander Alekseev

Attachment

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: Quorum commit for multiple synchronous replication.
Next
From: Fujii Masao
Date:
Subject: Re: Re: [sqlsmith] FailedAssertion("!(XLogCtl->Insert.exclusiveBackup)", File: "xlog.c", Line: 10200)