From 479cc8fed2ecd0e0dd313fe05c4337f84b67673c Mon Sep 17 00:00:00 2001 From: Hyuk Lee Date: Fri, 12 May 2017 15:50:12 +0900 Subject: [PATCH] Fix the svace issue (WGID : 212857) Change-Id: Iaa3c17a61273f5a816de42d449e650159810391e Signed-off-by: Hyuk Lee --- bt-otp/bt-otpserver.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bt-otp/bt-otpserver.c b/bt-otp/bt-otpserver.c index 3eff442..cc514cb 100644 --- a/bt-otp/bt-otpserver.c +++ b/bt-otp/bt-otpserver.c @@ -669,13 +669,15 @@ void convert_to_hex(struct object_metadata *object, char *type, char *value) localtime_r(&(object->first_created), tm); - value[1] = ((tm->tm_year+1900) >> 8) & 0xFF; - value[0] = (tm->tm_year+1900) & 0xFF; - value[2] = (tm->tm_mon+1) & 0xFF; - value[3] = tm->tm_mday & 0xFF; - value[4] = tm->tm_hour & 0xFF; - value[5] = tm->tm_min & 0xFF; - value[6] = tm->tm_sec & 0xFF; + if (tm) { + value[1] = ((tm->tm_year+1900) >> 8) & 0xFF; + value[0] = (tm->tm_year+1900) & 0xFF; + value[2] = (tm->tm_mon+1) & 0xFF; + value[3] = tm->tm_mday & 0xFF; + value[4] = tm->tm_hour & 0xFF; + value[5] = tm->tm_min & 0xFF; + value[6] = tm->tm_sec & 0xFF; + } } else if (!g_strcmp0(type, "id")) { -- 2.7.4