Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Alexander Lakhin <exclusion@gmail.com>, pgsql-bugs@lists.postgresql.org
Date: 2021-02-25T00:36:26Z
Lists: pgsql-bugs

Attachments

I wrote:
> Surely that breaks things entirely (if it doesn't, then we are badly
> under-testing this area).  A nil list is just a null pointer, so
> appending to "new_cte_list" later isn't going to affect what was
> previously put into the innerwiths list.

Here's a patch that I think fixes it correctly, including a test
case that doesn't work with your patch.

			regards, tom lane

Commits

  1. Fix list-manipulation bug in WITH RECURSIVE processing.