Re: BUG #15578: Executing json_populate_recordset with an empty array causes a segmentation fault

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: gregk(at)stoddarts(dot)com(dot)au, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15578: Executing json_populate_recordset with an empty array causes a segmentation fault
Date: 2019-01-07 04:59:18
Message-ID: 20190107045918.GC22498@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Jan 07, 2019 at 03:52:26AM +0000, PG Bug reporting form wrote:
> When executing json_populate_recordset/jsonb_populate_recordset with an
> empty array, a segmentation fault occurs and the server process is
> terminated. The issue occurs regardless of the type used. In previous
> versions this would return null.

This has been already fixed by a recent commit, which will be released
with 11.2 in the next round of minor releases (see also 595220a which
applies to REL_11_STABLE):
commit: eba2ce17121f198316d050e71d8bd049a43783ba
author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
date: Thu, 22 Nov 2018 15:14:01 -0500
committer: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
date: Thu, 22 Nov 2018 15:14:01 -0500
Fix another crash in json{b}_populate_recordset and
json{b}_to_recordset.

populate_recordset_worker() failed to consider the possibility that the
supplied JSON data contains no rows, so that update_cached_tupdesc never
got called. This led to a null-pointer dereference since commit 9a5e8ed28;
before that it led to a bogus "set-valued function called in context
that cannot accept a set" error. Fix by forcing the update to happen.

Per bug #15514. Back-patch to v11 as 9a5e8ed28 was. (If we were excited
about the bogus error, we could perhaps go back further, but it'd take more
work to figure out how to fix it in older branches. Given the lack of
field complaints about that aspect, I'm not excited.)

Discussion: https://postgr.es/m/15514-59d5b4c4065b178b@postgresql.org
--
Michael

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-01-07 05:12:28 Re: BUG #15578: Executing json_populate_recordset with an empty array causes a segmentation fault
Previous Message PG Bug reporting form 2019-01-07 03:52:26 BUG #15578: Executing json_populate_recordset with an empty array causes a segmentation fault