From 3a53056eef21fdba8c9cc8a7769d2bd55704b4bc Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Wed, 17 Mar 2021 16:06:58 +0900 Subject: [PATCH] Check if parameter is null for getter API Change-Id: I5dd1f23448ae2b99e4c5fe57be902d7a8d267286 Signed-off-by: Inkyun Kil --- lib/alarm-lib.c | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/alarm-lib.c b/lib/alarm-lib.c index bcd3d65..5ef84f7 100644 --- a/lib/alarm-lib.c +++ b/lib/alarm-lib.c @@ -785,15 +785,14 @@ EXPORT_API int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time) EXPORT_API int alarmmgr_get_time(const alarm_entry_t *alarm, alarm_date_t *time) { - base_info_t *base_info = (base_info_t *)alarm; - - if (alarm == NULL) { - LOGE("alarm is null"); + if (alarm == NULL || time == NULL) { + LOGE("alarm or time is null"); return ERR_ALARM_INVALID_PARAM; } - if (time != NULL) - memcpy(time, &base_info->start, sizeof(alarm_date_t)); + base_info_t *base_info = (base_info_t *)alarm; + + memcpy(time, &base_info->start, sizeof(alarm_date_t)); return ALARMMGR_RESULT_SUCCESS; } @@ -823,17 +822,14 @@ EXPORT_API int alarmmgr_set_repeat_mode(alarm_entry_t *alarm, EXPORT_API int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm, alarm_repeat_mode_t *repeat, int *interval) { - base_info_t *base_info = (base_info_t *)alarm; - - if (alarm == NULL) { - LOGE("alarm is null"); + if (alarm == NULL || repeat == NULL || interval == NULL) { + LOGE("alarm or repeat or interval is null"); return ERR_ALARM_INVALID_PARAM; } - if (repeat != NULL) - *repeat = base_info->mode.repeat; - if (interval != NULL) - *interval = base_info->mode.u_interval.interval; + base_info_t *base_info = (base_info_t *)alarm; + *repeat = base_info->mode.repeat; + *interval = base_info->mode.u_interval.interval; return ALARMMGR_RESULT_SUCCESS; } @@ -856,15 +852,14 @@ EXPORT_API int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type) EXPORT_API int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type) { - base_info_t *base_info = (base_info_t *)alarm; - - if (alarm == NULL) { - LOGE("alarm is null"); + if (alarm == NULL || alarm_type == NULL) { + LOGE("alarm or alarm_type is null"); return ERR_ALARM_INVALID_PARAM; } - if (alarm_type != NULL) - *alarm_type = base_info->alarm_type; + base_info_t *base_info = (base_info_t *)alarm; + + *alarm_type = base_info->alarm_type; return ALARMMGR_RESULT_SUCCESS; } @@ -913,6 +908,9 @@ EXPORT_API int alarmmgr_get_alarm_noti_info(alarm_id_t alarm_id, notification_h { int ret = 0; + if (noti == NULL) + return ERR_ALARM_INVALID_PARAM; + ret = __sub_init(); if (ret < 0) return ret; -- 2.7.4