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 @@ -304,6 +304,16 @@ static char *setlocale_perl(int category, char *locale);
304
304
static char *
305
305
hek2cstr (HE * he )
306
306
{
307
+ char * ret ;
308
+ SV * sv ;
309
+
310
+ /*
311
+ * HeSVKEY_force will return a temporary mortal SV*, so we need to make
312
+ * sure to free it with ENTER/SAVE/FREE/LEAVE
313
+ */
314
+ ENTER ;
315
+ SAVETMPS ;
316
+
307
317
/*-------------------------
308
318
* Unfortunately, while HeUTF8 is true for most things > 256, for values
309
319
* 128..255 it's not, but perl will treat them as unicode code points if
@@ -328,11 +338,17 @@ hek2cstr(HE *he)
328
338
* right thing
329
339
*-------------------------
330
340
*/
331
- SV * sv = HeSVKEY_force (he );
332
341
342
+ sv = HeSVKEY_force (he );
333
343
if (HeUTF8 (he ))
334
344
SvUTF8_on (sv );
335
- return sv2cstr (sv );
345
+ ret = sv2cstr (sv );
346
+
347
+ /* free sv */
348
+ FREETMPS ;
349
+ LEAVE ;
350
+
351
+ return ret ;
336
352
}
337
353
338
354
/*
You can’t perform that action at this time.
0 commit comments