From: | Tobias Florek <postgres(at)ibotty(dot)net> |
---|---|
To: | PGSQL-Novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | invalid memory alloc request size with extension url_decode |
Date: | 2014-08-28 14:26:09 |
Message-ID: | 53FF3C01.3010406@ibotty.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
hi all,
using the extension url_encode (not on pgxn) does not work in postgresql
9.3 (and 9.4). (i assume it works in earlier versions, but i have not
tested that.)
the testcase is the following.
create table t (id serial primary key, t1 text not null, t2 text);
insert into t (t1) values ('test');
update t set t2 = url_encode(t1);
it fails with
Error: invalid memory alloc request size 1452021511
for my untrained eye, the code [2] looks reasonable. it does use the
following idiom though.
static text *
encode(text *in_text, ...)
{
...
real_len = 0;
len = VARSIZE(in_text) - VARHDRSZ;
result = (text *) palloc(3 * len + VARHDRSZ);
write_ptr = VARDATA(result);
...
SET_VARSIZE(result, real_len + VARHDRSZ);
return result;
}
is that safe for "text" data type? how should it be replaced if not?
[1] https://github.com/okbob/url_encode
[2] https://github.com/okbob/url_encode/blob/master/src/url_encode.c
thank you in advance,
tobias florek
From | Date | Subject | |
---|---|---|---|
Next Message | Tobias Florek | 2014-08-28 14:29:17 | Re: invalid memory alloc request size with extension url_decode |
Previous Message | Marc Richter | 2014-08-28 08:26:44 | Re: PG 9.1 much slower than 8.2 ? |