Re: Dereferenced pointer in tablesample.c

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Petr Jelinek <petr(at)2ndquadrant(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Dereferenced pointer in tablesample.c
Date: 2015-06-30 16:47:52
Message-ID: 6975.1435682872@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Petr Jelinek <petr(at)2ndquadrant(dot)com> writes:
> On 2015-06-30 09:10, Michael Paquier wrote:
>> If the expression argstate is NULL when calling ExecInitExpr(), argstate
>> is going to be NULL and dereferenced afterwards, see execQual.c for more
>> details. Hence I think that the patch attached should be applied. Thoughts?

> Well, yes the ExecEvalExpr should be in the else block if we'd keep the
> NULL logic there.

> However after rereading the code, ISTM the ExecInitExpr will only return
> NULL if the argexpr is NULL and argexpr is added by ParseTableSample
> using the transformExpr on every argument which comes from grammar and
> those are a_exprs which AFAIK will never be NULL. So I actually think
> that the argstate can never be NULL in practice.

Indeed. ParseTableSample() is badly in need of a rewrite, but I agree
that it's not going to produce null expression trees.

> Patch attached.

Will push this shortly.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2015-06-30 17:21:00 Re: pg_rewind failure by file deletion in source server
Previous Message Alvaro Herrera 2015-06-30 16:37:06 Re: LWLock deadlock and gdb advice