From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | exclusion(at)gmail(dot)com |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #17912: Invalid memory access when converting plpython' array containing empty array |
Date: | 2023-04-28 15:14:06 |
Message-ID: | 1392974.1682694846@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> CREATE EXTENSION plpython3u;
> CREATE OR REPLACE FUNCTION test() RETURNS text[] AS $$
> return [[], "a"]
> $$ LANGUAGE plpython3u;
> SELECT test();
> As I can see, for the first case we get len = 0 in PLySequence_ToArray();
> elems, nulls palloc'ed with zero elements, but PLyObject_ToScalar() tries
> to write a value into nulls[0]...
Yeah. The calculation of the array size is being done in the wrong
place, so that we may update len to zero before breaking out of the
loop. But really it's poor coding for this function to be doing
its own calculation of the array size at all, rather than consulting
the authoritative ArrayGetNItems(). I think we need something like
the attached.
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
fix-PLySequence_ToArray.patch | text/x-diff | 1.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Lakhin | 2023-04-28 18:00:00 | Re: BUG #17912: Invalid memory access when converting plpython' array containing empty array |
Previous Message | Daniel Gustafsson | 2023-04-28 12:11:00 | Re: pg_basebackup: errors on macOS on directories with ".DS_Store" files |