Re: [HACKERS] Dereferenced pointer checks in data.c of ECPG

2015-02-25 Thread Michael Meskes
 A patch is attached, and the issue has been spotted by Coverity.
 Regards,

Thanks, committed.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at gmail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] Dereferenced pointer checks in data.c of ECPG

2015-02-24 Thread Michael Paquier
Hi all,

ecpg_get_data@data.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
diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c
index 2d0c118..d229c74 100644
--- a/src/interfaces/ecpg/ecpglib/data.c
+++ b/src/interfaces/ecpg/ecpglib/data.c
@@ -634,7 +634,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 	if (ires == NULL)
 	{
 		ecpg_log(ecpg_get_data on line %d: RESULT %s; errno %d\n,
- lineno, pval ? pval : , errno);
+ lineno, pval, errno);
 
 		if (INFORMIX_MODE(compat))
 		{
@@ -688,7 +688,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 	if (errno != 0)
 	{
 		ecpg_log(ecpg_get_data on line %d: RESULT %s; errno %d\n,
- lineno, pval ? pval : , errno);
+ lineno, pval, errno);
 
 		if (INFORMIX_MODE(compat))
 		{
@@ -736,7 +736,7 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 	if (errno != 0)
 	{
 		ecpg_log(ecpg_get_data on line %d: RESULT %s; errno %d\n,
- lineno, pval ? pval : , errno);
+ lineno, pval, errno);
 
 		if (INFORMIX_MODE(compat))
 		{

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers