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