Ticket #2041: 2041-missing-g_strdup_printf-retcheck-in-logging.c.patch

File 2041-missing-g_strdup_printf-retcheck-in-logging.c.patch, 814 bytes (added by vit_r, 14 years ago)

missing retcheck of g_strdup_printf in lib logging.c

  • lib/logging.c

    From 150965ec40a7b35b2459ccd5af0c8eacb59dd0c3 Mon Sep 17 00:00:00 2001
    From: Vit Rosin <vit_r@list.ru>
    Date: Fri, 19 Feb 2010 15:06:50 +0000
    Subject: [PATCH] missing retcheck of g_strdup_printf in logging.c
    
    ---
     lib/logging.c |    5 ++++-
     1 files changed, 4 insertions(+), 1 deletions(-)
    
    diff --git a/lib/logging.c b/lib/logging.c
    index c9de5d3..5223a05 100644
    a b mc_log(const char *fmt, ...) 
    6565        char *logfilename; 
    6666 
    6767        if (is_logging_enabled()) { 
    68                 va_start(args, fmt); 
    6968                logfilename = g_strdup_printf("%s/%s/log", home_dir, MC_USERCONF_DIR); 
     69                if (logfilename == NULL) 
     70                    return; 
     71 
     72                va_start(args, fmt); 
    7073                if ((f = fopen(logfilename, "a")) != NULL) { 
    7174                        (void)vfprintf(f, fmt, args); 
    7275                        (void)fclose(f);