File tree 1 file changed +18
-2
lines changed
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);
308
308
static char *
309
309
hek2cstr (HE * he )
310
310
{
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
+
311
321
/*-------------------------
312
322
* Unfortunately, while HeUTF8 is true for most things > 256, for values
313
323
* 128..255 it's not, but perl will treat them as unicode code points if
@@ -332,11 +342,17 @@ hek2cstr(HE *he)
332
342
* right thing
333
343
*-------------------------
334
344
*/
335
- SV * sv = HeSVKEY_force (he );
336
345
346
+ sv = HeSVKEY_force (he );
337
347
if (HeUTF8 (he ))
338
348
SvUTF8_on (sv );
339
- return sv2cstr (sv );
349
+ ret = sv2cstr (sv );
350
+
351
+ /* free sv */
352
+ FREETMPS ;
353
+ LEAVE ;
354
+
355
+ return ret ;
340
356
}
341
357
342
358
/*
You can’t perform that action at this time.
0 commit comments