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

Commitf84997c

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 parent8976360 commitf84997c

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
@@ -303,6 +303,16 @@ static char *setlocale_perl(int category, char *locale);
303303
staticchar*
304304
hek2cstr(HE*he)
305305
{
306+
char*ret;
307+
SV*sv;
308+
309+
/*
310+
* HeSVKEY_force will return a temporary mortal SV*, so we need to make
311+
* sure to free it with ENTER/SAVE/FREE/LEAVE
312+
*/
313+
ENTER;
314+
SAVETMPS;
315+
306316
/*-------------------------
307317
* Unfortunately, while HeUTF8 is true for most things > 256, for values
308318
* 128..255 it's not, but perl will treat them as unicode code points if
@@ -327,11 +337,17 @@ hek2cstr(HE *he)
327337
* right thing
328338
*-------------------------
329339
*/
330-
SV*sv=HeSVKEY_force(he);
331340

341+
sv=HeSVKEY_force(he);
332342
if (HeUTF8(he))
333343
SvUTF8_on(sv);
334-
returnsv2cstr(sv);
344+
ret=sv2cstr(sv);
345+
346+
/* free sv */
347+
FREETMPS;
348+
LEAVE;
349+
350+
returnret;
335351
}
336352

337353
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp