Re: Possible pointer dereference

From: Gaetano Mendola <mendola(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Possible pointer dereference
Date: 2015-05-28 20:35:17
Message-ID: CAJycT5qeCPy-zx0VinJAocnOs3DZ_BPqAcXWeX4hL4+hSvrRfw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While at it the assert(cnfa != NULL && cnfa->nstates != 0); at
src/backend/regex/rege_dfa.c:282
is issued too late indeed at line 278 and 279 cnfa was already
dereferenced.

Same for assert(t != NULL) in src/backend/regex/regexec.c:821 is issued way
too late.

On Thu, 28 May 2015 at 15:59 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> > On Wed, May 27, 2015 at 8:57 PM, Haribabu Kommi
> > <kommi(dot)haribabu(at)gmail(dot)com> wrote:
> >> By correcting the following way will solve the problem.
> >> return ts ? (*ts != 0) : false; instead of retun *ts != 0;
> >> Attached a patch for it.
>
> > If the only caller always passes a valid pointer, there's no point in
> > adding this check. We have many functions in our source base that
> > assume that the caller will pass a valid pointer, and changing them
> > all would make the code bigger, harder to read, and possibly slower,
> > without any real benefit.
>
> Well, we should either install something like Haribabu's patch, or else
> remove the existing tests in the function that allow "ts" to be NULL.
> And the function's API contract comment needs to be clarified in either
> case; the real bug here is lack of a specification.
>
> I don't particularly have an opinion on whether it's valuable to allow
> this function to be called without receiving a timestamp back. Perhaps
> the authors of the patch can comment on that.
>
> regards, tom lane
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Gaetano Mendola 2015-05-28 20:42:37 Re: useless assignment pointer argument
Previous Message Joshua D. Drake 2015-05-28 20:22:09 Re: RFC: Remove contrib entirely