fix crash caused by referencing memory without allocation. 37/70137/2
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 18 May 2016 08:34:31 +0000 (17:34 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Wed, 18 May 2016 08:36:30 +0000 (17:36 +0900)
Change-Id: Ie5f5e333d1e803ea114c629ffe175f81b4b1040b

src/lib/pepper/utils-log.c

index 15e66e003b27d34ba5c828282a6892fda50e4df6..dab511b2a8266ffc46a076e9ad4b4f7103924941 100644 (file)
@@ -52,6 +52,10 @@ pepper_print_timestamp(void)
 
        gettimeofday(&tv, NULL);
 
+       brokendown_time = calloc(1, sizeof(*brokendown_time));
+       if (!brokendown_time)
+               return fprintf(pepper_log_file, "failed to calloc for brokendown_time\n");
+
        localtime_r(&tv.tv_sec, brokendown_time);
        if (brokendown_time == NULL)
                return fprintf(pepper_log_file, "[(NULL)localtime] ");
@@ -65,6 +69,8 @@ pepper_print_timestamp(void)
 
        strftime(string, sizeof string, "%H:%M:%S", brokendown_time);
 
+       free(brokendown_time);
+
        return fprintf(pepper_log_file, "[%s.%03li] ", string, tv.tv_usec / 1000);
 }