mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-05 10:20:55 +00:00
tools: acrntrace: fix NULL pointer issue in create_trace_file_dir()
Fix NULL pointer dereference if 'localtime()' execution encountered an error, in create_trace_file_dir(). Signed-off-by: Yan, Like <like.yan@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
0f847e35a7
commit
1f3e38b306
@ -173,9 +173,13 @@ static int create_trace_file_dir(char *dir)
|
|||||||
|
|
||||||
time(&timep);
|
time(&timep);
|
||||||
p = localtime(&timep);
|
p = localtime(&timep);
|
||||||
snprintf(time_str, TIME_STR_LEN, "%d%02d%02d-%02d%02d%02d",
|
if (p)
|
||||||
(1900 + p->tm_year), (1 + p->tm_mon), p->tm_mday,
|
snprintf(time_str, TIME_STR_LEN, "%d%02d%02d-%02d%02d%02d",
|
||||||
p->tm_hour, p->tm_min, p->tm_sec);
|
(1900 + p->tm_year), (1 + p->tm_mon), p->tm_mday,
|
||||||
|
p->tm_hour, p->tm_min, p->tm_sec);
|
||||||
|
else
|
||||||
|
snprintf(time_str, TIME_STR_LEN, "00000000-000000");
|
||||||
|
|
||||||
pr_info("start tracing at %s\n", time_str);
|
pr_info("start tracing at %s\n", time_str);
|
||||||
|
|
||||||
snprintf(dir, TRACE_FILE_DIR_LEN, "%s%s", TRACE_FILE_ROOT, time_str);
|
snprintf(dir, TRACE_FILE_DIR_LEN, "%s%s", TRACE_FILE_ROOT, time_str);
|
||||||
|
Loading…
Reference in New Issue
Block a user