Possible NULL pointer deferenced (src/interfaces/libpq/fe-exec.c (line 563)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
Subject: Possible NULL pointer deferenced (src/interfaces/libpq/fe-exec.c (line 563)
Date: 2020-06-20 14:07:49
Message-ID: CAEudQAr7RQZkLbVQE3J91O2KbLFtggLDbnZvr+QmNUHT2+z1Ng@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Mark,
please, can you take a look?

This possible bug was appeared before, see at:
1. https://bugzilla.redhat.com/show_bug.cgi?id=879803

The trap still persist, in HEAD see:

src/interfaces/libpq/fe-exec.c (line 563)
/* If there's enough space in the current block, no problem. */
if (nBytes <= (size_t) res->spaceLeft)
{
space = res->curBlock->space + res->curOffset;
res->curOffset += nBytes;
res->spaceLeft -= nBytes;

return space;
}

The res->curBlock pointer possibly, can be NULL here (line 563).

See at:
src/interfaces/libpq/fe-exec.c (line 585)
if (res->curBlock)

The path is res->curBlock be NULL and res->spaceLeft > nBytes.

If res->curBlock it not can be NULL, inside pqResultAlloc function, why is
verified against NULL at line 585?

regards,
Ranier Vilela

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-06-20 14:12:33 Re: git.postgresql.org ok?
Previous Message vignesh C 2020-06-20 13:15:20 Re: Include access method in listTables output