Fix for Coverity perl5 CID 45366: Use after free (USE_AFTER_FREE) pass_freed_arg...
authorJarkko Hietaniemi <jhi@iki.fi>
Fri, 25 Apr 2014 00:33:16 +0000 (20:33 -0400)
committerTony Cook <tony@develop-help.com>
Mon, 28 Apr 2014 23:20:13 +0000 (09:20 +1000)
Printfing save-pvs after freeing them.

locale.c

index 3fc55a8..6e8728c 100644 (file)
--- 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;
     }