From d37662c0fabaaa893c0d695034fa83b9235c6872 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Thu, 24 Apr 2014 20:33:16 -0400 Subject: [PATCH] Fix for Coverity perl5 CID 45366: Use after free (USE_AFTER_FREE) pass_freed_arg: Passing freed pointer save_input_locale as an argument to PerlIO_printf. Printfing save-pvs after freeing them. --- locale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locale.c b/locale.c index 3fc55a8..6e8728c 100644 --- a/locale.c +++ b/locale.c @@ -1181,20 +1181,20 @@ S_is_cur_LC_category_utf8(pTHX_ int category) && *(save_input_locale + final_pos - 3) == '5' && *(save_input_locale + final_pos - 4) == '6') { - Safefree(save_input_locale); DEBUG_L(PerlIO_printf(Perl_debug_log, "Locale %s ends with 10056 in name, is UTF-8 locale\n", save_input_locale)); + Safefree(save_input_locale); return TRUE; } #endif /* Other common encodings are the ISO 8859 series, which aren't UTF-8 */ if (instr(save_input_locale, "8859")) { - Safefree(save_input_locale); DEBUG_L(PerlIO_printf(Perl_debug_log, "Locale %s has 8859 in name, not UTF-8 locale\n", save_input_locale)); + Safefree(save_input_locale); return FALSE; } -- 2.7.4