pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: starbugs@qq.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16190: The usage of NULL pointer in refint.c
Date: Mon, 6 Jan 2020 14:18:00 +0900
Message-ID: <20200106051800.GL3598@paquier.xyz> (raw)
In-Reply-To: <16190-70181c803641c3dc@postgresql.org>
References: <16190-70181c803641c3dc@postgresql.org>

On Mon, Jan 06, 2020 at 03:39:36AM +0000, PG Bug reporting form wrote:
> We checked the code in file “refint.c” and there is one error occurring in
> line 636. This error is caused by the usage of pointer with NULL value. The
> code in this line is “newp->ident = strdup(ident);” The pointer “newp” is
> defined by the code in line 615 as “EPlan *newp;” and initialized by the
> code in line 628 as “newp = *eplan + i;” or in line 632 as “newp = *eplan =
> (EPlan *) malloc(sizeof(EPlan));” according to different conditions. In the
> first condition, the “*eplan” is valued by the code “*eplan = (EPlan *)
> realloc(*eplan, (i + 1) * sizeof(EPlan));” in line 627. We found the code
> hasn’t checked if the process “realloc” and “malloc” are success or not
> which directly define the value of “*eplan”. The program should check the
> effectiveness of the return value of function “realloc” and “malloc” to
> avoid this error.

It could be better to switch all that to not use directly system
calls, and rely properly on a high-level memory context with
palloc-like allocations.  There could be also an argument to just
remove the module per the lack of attention it is getting, though it
is still useful as an example of use for SPI, and the docs mention
it for that.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (11+ messages)  latest in thread

Message-ID: <20200106051800.GL3598@paquier.xyz>
Permalink:  ../20200106051800.GL3598@paquier.xyz/
Also on:    postgresql.org/message-id/20200106051800.GL3598@paquier.xyz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: michael@paquier.xyz, starbugs@qq.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #16190: The usage of NULL pointer in refint.c
  In-Reply-To: <20200106051800.GL3598@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox