postgresql/src/pl/plperl/expected
Richard Guo 4015abe14b plperl: Fix NULL pointer dereference for forged array object
In get_perl_array_ref(), for a PostgreSQL::InServer::ARRAY object, we
look up its "array" key with hv_fetch_string() and then inspect the
returned SV.  However, hv_fetch_string() returns a NULL pointer when
the key is absent, and the code dereferenced that result without first
checking whether the pointer itself was NULL.  As a result, a plperl
function returning a forged PostgreSQL::InServer::ARRAY object that
lacks the "array" key would crash the backend with a segmentation
fault.

Fix this by checking the pointer returned by hv_fetch_string() before
dereferencing it, matching how other callers in this file already
guard the result.  With the check in place, such an object falls
through to the existing error report instead of crashing.

Author: Xing Guo <higuoxing@gmail.com>
Reviewed-by: Richard Guo <guofenglinux@gmail.com>
Discussion: https://postgr.es/m/CACpMh+DYgcnqZwQLXXuxQcehJTd7T8UmKWSLsK4mFBEp9G2ajA@mail.gmail.com
Backpatch-through: 14
2026-06-24 09:09:48 +09:00
..
plperl.out Fix pl/perl test case so it will still work under Perl 5.36. 2022-06-01 16:15:47 -04:00
plperl_array.out plperl: Fix NULL pointer dereference for forged array object 2026-06-24 09:09:48 +09:00
plperl_call.out Support for OUT parameters in procedures 2020-10-05 09:21:43 +02:00
plperl_elog.out EUC_CN, EUC_JP, EUC_KR, EUC_TW: Skip U+00A0 tests instead of failing. 2026-02-25 18:13:22 -08:00
plperl_elog_1.out EUC_CN, EUC_JP, EUC_KR, EUC_TW: Skip U+00A0 tests instead of failing. 2026-02-25 18:13:22 -08:00
plperl_env.out Fix cross-version upgrade tests. 2024-11-11 13:57:21 -05:00
plperl_init.out Fix missed corner cases for grantable permissions on GUCs. 2022-07-19 17:21:55 -04:00
plperl_lc.out Remove recently added PL/Perl encoding tests 2012-07-17 13:26:25 -04:00
plperl_lc_1.out Remove recently added PL/Perl encoding tests 2012-07-17 13:26:25 -04:00
plperl_plperlu.out Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
plperl_setup.out tests: Rename conflicting role names 2022-10-05 10:43:13 -07:00
plperl_shared.out Remember the source GucContext for each GUC parameter. 2011-10-04 16:13:50 -04:00
plperl_transaction.out Fix SPI's handling of errors during transaction commit. 2022-02-28 12:45:36 -05:00
plperl_trigger.out Virtual generated columns 2025-02-07 09:46:59 +01:00
plperl_unicode.out EUC_CN, EUC_JP, EUC_KR, EUC_TW: Skip U+00A0 tests instead of failing. 2026-02-25 18:13:22 -08:00
plperl_unicode_1.out EUC_CN, EUC_JP, EUC_KR, EUC_TW: Skip U+00A0 tests instead of failing. 2026-02-25 18:13:22 -08:00
plperl_util.out Support domains over composite types in PL/Perl. 2017-10-28 14:02:21 -04:00
plperlu.out Rearrange the handling of error context reports. 2015-09-05 11:58:33 -04:00