BUG #16190: The usage of NULL pointer in refint.c - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16190: The usage of NULL pointer in refint.c
Date
Msg-id 16190-70181c803641c3dc@postgresql.org
Whole thread Raw
Responses Re: BUG #16190: The usage of NULL pointer in refint.c  (Michael Paquier <michael@paquier.xyz>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16190
Logged by:          Jian Zhang
Email address:      starbugs@qq.com
PostgreSQL version: 12.1
Operating system:   Linux
Description:

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.


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #16189: The usage of NULL pointer in indexpath.c
Next
From: PG Bug reporting form
Date:
Subject: BUG #16191: Errors of division by zero occur in several files.