Dereferenced pointer checks in data.c of ECPG

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Dereferenced pointer checks in data.c of ECPG
Date: 2015-02-25 06:05:03
Message-ID: CAB7nPqTVc7_LYQXnqhuEf+u-_EGzo5tiPZYdfems2+i9hsJmHw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

ecpg_get_data(at)data(dot)c is using to null-pointer checks for pval but it
happens that we have the guarantee that those pointers are never NULL, see
for example this piece of code at the code of ecpg_get_data():
/* pval is a pointer to the value */
if (!pval)
{
/*
* This should never happen because we already checked that
we found
* at least one tuple, but let's play it safe.
*/
ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA,
NULL);
return (false);
}
A patch is attached, and the issue has been spotted by Coverity.
Regards,
--
Michael

Attachment Content-Type Size
20150225_ecpg_get_data_null_ptrs.patch text/x-patch 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Kirkwood 2015-02-25 06:59:12 Re: Unable to build pg_rewind
Previous Message Tom Lane 2015-02-25 05:56:30 Re: Precedence of standard comparison operators