Re: Report a potential bug caused by a improper call to pfree() - Mailing list pgsql-bugs

From Kyotaro Horiguchi
Subject Re: Report a potential bug caused by a improper call to pfree()
Date
Msg-id 20220131.114144.1534169725851050672.horikyota.ntt@gmail.com
Whole thread Raw
In response to Re: Report a potential bug caused by a improper call to pfree()  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
At Sun, 30 Jan 2022 10:29:27 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote in 
> Julien Rouhaud <rjuju123@gmail.com> writes:
> > On Sun, Jan 30, 2022 at 10:47:18AM +0800, wliang@stu.xidian.edu.cn wrote:
> >> 1160                 /* Pop the stack */
> >> 1161                 parent = stack->parent;
> >> 1162                 pfree(stack);
> >> 
> >> I think it may be a potential bug and can be fixed without any side-effect as:
> >> 
> >> 
> >> ++        if (stack != &tail)
> >> 1162                pfree(stack);
> 
> > I don't think it's necessary, it should be guaranteed that something as been
> > pushed on the tail, ie. there shouldn't be a WJB_END_* before a corresponding
> > begin.
> 
> I've not checked the logic, but the lack of any reported crashes here
> seems to confirm that there's no bug.

As a cross-check, I agree to Julien. The parser starts reading from
OBJECT_START or ARRAY_START (or bare scalar) so if we had the stack
empty there, we *should properly crash* instead of pretending that a
problem were not exitsting at all.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Missing include in float.h
Next
From: PG Bug reporting form
Date:
Subject: BUG #17388: postgis cant be installed on postgres 11 and centos 7