From: seolheui kim Date: Wed, 9 May 2018 01:41:27 +0000 (+0900) Subject: Fix coverity issues X-Git-Tag: submit/tizen/20180509.022227^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f3738ee1c59096f3140e9a0f75d79f808db08d2;p=platform%2Fcore%2Fsecurity%2Fode-ui.git Fix coverity issues - fix resource memory leak - fix unchecked return value Change-Id: Ib8cd70fcc0c995c4c753ce5b86599854ddba82e2 Signed-off-by: seolheui kim --- diff --git a/ode/src/interface/tools/battery.cpp b/ode/src/interface/tools/battery.cpp index daa0d94..9c2213b 100644 --- a/ode/src/interface/tools/battery.cpp +++ b/ode/src/interface/tools/battery.cpp @@ -47,7 +47,11 @@ Battery::~Battery() bool Battery::getChargerConnected() { bool connected = false; - ::runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &connected); + + if (::runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &connected) + != RUNTIME_INFO_ERROR_NONE) + return false; + return connected; } diff --git a/ode/src/widgets/appcontrol.cpp b/ode/src/widgets/appcontrol.cpp index 80f1ecf..531db0b 100644 --- a/ode/src/widgets/appcontrol.cpp +++ b/ode/src/widgets/appcontrol.cpp @@ -45,6 +45,9 @@ AppControl::~AppControl() { if (appControl != nullptr) ::app_control_destroy(appControl); + + if (caller != nullptr) + ::app_control_destroy(caller); } AppControl::operator app_control_h() diff --git a/ode/src/widgets/notification.cpp b/ode/src/widgets/notification.cpp index 92da321..694c834 100644 --- a/ode/src/widgets/notification.cpp +++ b/ode/src/widgets/notification.cpp @@ -15,7 +15,7 @@ * limitations under the License. * */ - +#include #include "notification.h" Notification::Notification(notification_type_e type) @@ -31,19 +31,25 @@ Notification::~Notification() void Notification::setTitle(const std::string &title) { - ::notification_set_text(notification, NOTIFICATION_TEXT_TYPE_TITLE, + int ret = ::notification_set_text(notification, NOTIFICATION_TEXT_TYPE_TITLE, title.c_str(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE); + if (ret != NOTIFICATION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set title text to notification"); } void Notification::setContentText(const std::string &content) { - ::notification_set_text(notification, NOTIFICATION_TEXT_TYPE_CONTENT, + int ret = ::notification_set_text(notification, NOTIFICATION_TEXT_TYPE_CONTENT, content.c_str(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE); + if (ret != NOTIFICATION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set content text to notification"); } void Notification::setProgress(double value) { - ::notification_set_progress(notification, value); + if (::notification_set_progress(notification, value) + != NOTIFICATION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set progress to notification"); } double Notification::getProgress() @@ -55,27 +61,33 @@ double Notification::getProgress() void Notification::setLayout(notification_ly_type_e type) { - ::notification_set_layout(notification, type); + if (::notification_set_layout(notification, type) != NOTIFICATION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set layout to notification"); } void Notification::setImage(const std::string &path) { - ::notification_set_image(notification, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, path.c_str()); + if (::notification_set_image(notification, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, path.c_str()) != NOTIFICATION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set image to notification"); } void Notification::setAppControl(AppControl &appControl) { - ::notification_set_launch_option(notification, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, appControl); + if (::notification_set_launch_option(notification, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, appControl) + != NOTIFICATION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set launch option to notification"); } void Notification::update() { - ::notification_update(notification); + if (::notification_update(notification) != NOTIFICATION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to update notification"); } void Notification::post() { - ::notification_post(notification); + if (::notification_post(notification) != NOTIFICATION_ERROR_NONE) + dlog_print(DLOG_ERROR, LOG_TAG, "Failed to post notification"); } void Notification::dispose() diff --git a/secure-erase/src/ui.c b/secure-erase/src/ui.c index 216482f..6cf2fa3 100644 --- a/secure-erase/src/ui.c +++ b/secure-erase/src/ui.c @@ -33,25 +33,33 @@ static notification_h add_notification(notification_type_e type, const char *tit if (title) { ret = notification_set_text(handle, NOTIFICATION_TEXT_TYPE_TITLE, title, NULL, NOTIFICATION_VARIABLE_TYPE_NONE); - if (ret != NOTIFICATION_ERROR_NONE) + if (ret != NOTIFICATION_ERROR_NONE) { + notification_free(handle); return NULL; + } } if (content) { ret = notification_set_text(handle, NOTIFICATION_TEXT_TYPE_CONTENT, content, NULL, NOTIFICATION_VARIABLE_TYPE_NONE); - if (ret != NOTIFICATION_ERROR_NONE) + if (ret != NOTIFICATION_ERROR_NONE) { + notification_free(handle); return NULL; + } } if (image) { ret = notification_set_image(handle, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, image); - if (ret != NOTIFICATION_ERROR_NONE) + if (ret != NOTIFICATION_ERROR_NONE) { + notification_free(handle); return NULL; + } } ret = notification_set_layout(handle, layout); - if (ret != NOTIFICATION_ERROR_NONE) + if (ret != NOTIFICATION_ERROR_NONE) { + notification_free(handle); return NULL; + } return handle; }