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