File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,16 @@ static char *setlocale_perl(int category, char *locale);
308308static char *
309309hek2cstr (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- return sv2cstr (sv );
349+ ret = sv2cstr (sv );
350+
351+ /* free sv */
352+ FREETMPS ;
353+ LEAVE ;
354+
355+ return ret ;
340356}
341357
342358/*
You can’t perform that action at this time.
0 commit comments