From 966b95ea8b1cf091aefa100799d184fb7d2c8aa4 Mon Sep 17 00:00:00 2001 From: "jh8801.jung" Date: Fri, 17 Feb 2017 19:59:02 +0900 Subject: [PATCH] Fix svace issue for 118 checkers Signed-off-by: Jihoon Jung Change-Id: I7ae7337a60964a03e448008c6ff7c8c98d6cd461 --- CMakeLists.txt | 2 -- packaging/nfc-plugin-emul.spec | 2 +- src/oem/oem_emul.c | 19 +++++++++++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5d34c1..a83b598 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,5 +38,3 @@ ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} pthread "-ldl") INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib/nfc) - - diff --git a/packaging/nfc-plugin-emul.spec b/packaging/nfc-plugin-emul.spec index c8baaa8..7676943 100644 --- a/packaging/nfc-plugin-emul.spec +++ b/packaging/nfc-plugin-emul.spec @@ -1,6 +1,6 @@ Name: nfc-plugin-emul Summary: NFC emul plugin -Version: 0.0.20 +Version: 0.0.21 Release: 0 Group: TO_BE/FILLED_IN License: Apache-2.0 diff --git a/src/oem/oem_emul.c b/src/oem/oem_emul.c index e7a223e..c636b14 100755 --- a/src/oem/oem_emul.c +++ b/src/oem/oem_emul.c @@ -1140,6 +1140,8 @@ static bool _net_nfc_create_ndef_from_emulMsg(emulMsg_s *emul_msg) _net_nfc_store_ndef_message(&rawdata); + _nfc_emul_util_free_mem(rawdata.buffer); + DEBUG_EMUL_END(); return retval; @@ -1257,9 +1259,11 @@ static void _net_nfc_destroy_emulMsg(emulMsg_s *emul_msg) { DEBUG_EMUL_BEGIN(); - if(emul_msg != NULL && emul_msg->file_data != NULL) + if(emul_msg != NULL) { - free(emul_msg->file_data); + if(emul_msg->file_data != NULL) + free(emul_msg->file_data); + free(emul_msg); } @@ -1485,6 +1489,8 @@ static void _net_nfc_llcp_create_snep_server_msg(snep_command_field_e resp_field if(rawdata.length > 0) memcpy(temp, rawdata.buffer, rawdata.length); + _nfc_emul_util_free_mem(rawdata.buffer); + DEBUG_EMUL_END(); } @@ -1506,6 +1512,7 @@ static bool _net_nfc_make_llcp_data(emulMsg_s *emul_msg) data_s rawdata = { NULL, 0 }; _net_nfc_retrieve_ndef_message(&rawdata); + _nfc_emul_util_free_mem(rawdata.buffer); if (emul_msg->record_count == 0 || rawdata.length == 0) { @@ -2201,6 +2208,7 @@ static bool net_nfc_emul_controller_check_ndef(net_nfc_target_handle_s* handle, DEBUG_EMUL_BEGIN(); _net_nfc_retrieve_ndef_message(&rawdata); + _nfc_emul_util_free_mem(rawdata.buffer); if (_net_nfc_emul_get_is_tag_attached()) { @@ -2273,7 +2281,10 @@ static bool net_nfc_emul_controller_read_ndef(net_nfc_target_handle_s* handle, d *result = _net_nfc_retrieve_ndef_message(&rawdata); if(*result != NET_NFC_OK) + { + _nfc_emul_util_free_mem(rawdata.buffer); return false; + } real_data_size = rawdata.length; @@ -2281,6 +2292,7 @@ static bool net_nfc_emul_controller_read_ndef(net_nfc_target_handle_s* handle, d { DEBUG_ERR_MSG("read ndef_msg is failed >>> real_data_size is zero"); *result = NET_NFC_NO_NDEF_MESSAGE; + _nfc_emul_util_free_mem(rawdata.buffer); return false; } @@ -2289,6 +2301,7 @@ static bool net_nfc_emul_controller_read_ndef(net_nfc_target_handle_s* handle, d if(*data == NULL) { *result = NET_NFC_ALLOC_FAIL; + _nfc_emul_util_free_mem(rawdata.buffer); return false; } @@ -2299,11 +2312,13 @@ static bool net_nfc_emul_controller_read_ndef(net_nfc_target_handle_s* handle, d { free(*data); *result = NET_NFC_ALLOC_FAIL; + _nfc_emul_util_free_mem(rawdata.buffer); return false; } /* copy rawdata to data->buffer */ memcpy((*data)->buffer, rawdata.buffer, real_data_size); + _nfc_emul_util_free_mem(rawdata.buffer); DEBUG_EMUL_END(); -- 2.7.4