Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbd1154e

Browse files
committed
plperl: Fix memory leak in hek2cstr
Backpatch all the way back to 9.1, where it was introduced by commit50d89d4.Reported by Sergey Burladyan in #9223Author: Alex Hunsaker
1 parent0268d21 commitbd1154e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

‎src/pl/plperl/plperl.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,16 @@ static char *setlocale_perl(int category, char *locale);
308308
staticchar*
309309
hek2cstr(HE*he)
310310
{
311+
char*ret;
312+
SV*sv;
313+
314+
/*
315+
* HeSVKEY_force will return a temporary mortal SV*, so we need to make
316+
* sure to free it with ENTER/SAVE/FREE/LEAVE
317+
*/
318+
ENTER;
319+
SAVETMPS;
320+
311321
/*-------------------------
312322
* Unfortunately, while HeUTF8 is true for most things > 256, for values
313323
* 128..255 it's not, but perl will treat them as unicode code points if
@@ -332,11 +342,17 @@ hek2cstr(HE *he)
332342
* right thing
333343
*-------------------------
334344
*/
335-
SV*sv=HeSVKEY_force(he);
336345

346+
sv=HeSVKEY_force(he);
337347
if (HeUTF8(he))
338348
SvUTF8_on(sv);
339-
returnsv2cstr(sv);
349+
ret=sv2cstr(sv);
350+
351+
/* free sv */
352+
FREETMPS;
353+
LEAVE;
354+
355+
returnret;
340356
}
341357

342358
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp