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

Commitbd0e74a

Browse files
committed
Fix breakage from earlier plperl fix.
Apparently the perl garbage collector was a bit too eager, so herewe control when the new SV is garbage collected.
1 parent7e53515 commitbd0e74a

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

‎src/pl/plperl/plperl_helpers.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,32 @@ utf_e2u(const char *str)
4545
staticinlinechar*
4646
sv2cstr(SV*sv)
4747
{
48-
char*val;
48+
char*val,*res;
4949
STRLENlen;
50+
SV*nsv;
5051

5152
/*
5253
* get a utf8 encoded char * out of perl. *note* it may not be valid utf8!
5354
*
5455
* SvPVutf8() croaks nastily on certain things, like typeglobs and
55-
* readonlyobject such as $^V. That's a perl bug - it's not supposed to
56-
* happen. To avoid crashing the backend, we make amortalcopy of the
57-
* sv before passing it to SvPVutf8(). The copywill begarbage collected
58-
*very soon (see perldoc perlguts).
56+
* readonlyobjects such as $^V. That's a perl bug - it's not supposed to
57+
* happen. To avoid crashing the backend, we make a copy of the
58+
* sv before passing it to SvPVutf8(). The copyisgarbage collected
59+
*when we're done with it.
5960
*/
60-
val=SvPVutf8(sv_mortalcopy(sv),len);
61+
nsv=newSVsv(sv);
62+
val=SvPVutf8(nsv,len);
6163

6264
/*
63-
* we useperls length in the event we had an embedded null byte to ensure
65+
* we useperl's length in the event we had an embedded null byte to ensure
6466
* we error out properly
6567
*/
66-
returnutf_u2e(val,len);
68+
res=utf_u2e(val,len);
69+
70+
/* safe now to garbage collect the new SV */
71+
SvREFCNT_dec(nsv);
72+
73+
returnres;
6774
}
6875

6976
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp