IS JSON/JSON(): Protect against expressions uncoercible to text
Álvaro Herrera <alvherre@kurilemu.de>
IS JSON/JSON(): Protect against expressions uncoercible to text transformJsonParseArg() was not careful enough on generation of transformed expressions when starting from expressions that are not coercible to text but are in the string type category: it failed to verify that coerce_to_target_type() succeeds, and returned a NULL pointer. This leads to a later NULL dereference and crash at executor time. This escaped noticed because it cannot happen for built-in types, all of which have casts to text. Only user-created types are potentially problematic. Fix by raising an error when a cast to text doesn't exist. This mistake came in with commit 6ee30209a6f1. Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com> Reported-by: Chi Zhang <798604270@qq.com> Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com> Backpatch-through: 16 Discussion: https://postgr.es/m/19491-7aafc221ec63f288@postgresql.org
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/nodes/makefuncs.c | modified | +2 −0 |
| src/backend/parser/parse_expr.c | modified | +10 −0 |
| src/test/regress/expected/sqljson.out | modified | +36 −0 |
| src/test/regress/sql/sqljson.sql | modified | +22 −0 |
Discussion
- BUG #19491: Segmentation fault triggered by IS NULL 7 messages · 2026-05-22 → 2026-06-11