From a118050c5288f9b5acd580f81de0a96453c2f7bf Mon Sep 17 00:00:00 2001 From: "chleun.moon" Date: Mon, 7 Aug 2017 18:46:53 +0900 Subject: [PATCH] [WGID-258847] Add null check after malloc Change-Id: Icff55bff08bc48c3b4e86593eb1def358dc34fdd Signed-off-by: cheoleun --- packaging/ug-setting-wifidirect-efl.spec | 2 +- popup-wifidirect/src/wfd-app-util.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packaging/ug-setting-wifidirect-efl.spec b/packaging/ug-setting-wifidirect-efl.spec index 586d522..e0ca6da 100644 --- a/packaging/ug-setting-wifidirect-efl.spec +++ b/packaging/ug-setting-wifidirect-efl.spec @@ -1,6 +1,6 @@ Name: ug-setting-wifidirect-efl Summary: Wi-Fi Direct setting UI gadget -Version: 1.11.85 +Version: 1.11.86 Release: 1 Group: Applications/Network License: Flora-1.1 diff --git a/popup-wifidirect/src/wfd-app-util.c b/popup-wifidirect/src/wfd-app-util.c index 1c40a83..c61b9e3 100644 --- a/popup-wifidirect/src/wfd-app-util.c +++ b/popup-wifidirect/src/wfd-app-util.c @@ -120,6 +120,11 @@ static void _move_data_to_app_control(const char *key, const int type, if (type == BUNDLE_TYPE_STR) { bundle_keyval_get_basic_val((bundle_keyval_t *) kv, &ptr, &size); buff = malloc(sizeof(char) * size + 1); + if (buff == NULL) { + WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to allocate memory"); + __WFD_APP_FUNC_EXIT__; + return; + } snprintf(buff, size + 1, "%s", ((char*) ptr)); WFD_APP_LOG(WFD_APP_LOG_ERROR, "Found STR -KEY: %s, VAL: %s, SIZE: %d", key, buff, size); @@ -128,6 +133,11 @@ static void _move_data_to_app_control(const char *key, const int type, } else if (type == BUNDLE_TYPE_BYTE) { bundle_keyval_get_basic_val((bundle_keyval_t *) kv, &ptr, &size); buff = malloc(sizeof(char) * size + 1); + if (buff == NULL) { + WFD_APP_LOG(WFD_APP_LOG_ERROR, "Failed to allocate memory"); + __WFD_APP_FUNC_EXIT__; + return; + } snprintf(buff, size + 1, "%s", ((char*) ptr)); WFD_APP_LOG(WFD_APP_LOG_ERROR, "Found STR -KEY: %s, VAL: %s, SIZE: %d", key, buff, size); -- 2.7.4