From 6a45008ff81283c9b26db58d4b434a15430f9b19 Mon Sep 17 00:00:00 2001 From: "jh8801.jung" Date: Wed, 29 Mar 2017 19:13:22 +0900 Subject: [PATCH] Sync with 3.0 : Ver. 0.0.20 to 0.0.23 Change-Id: I051e6bf90b32357be0c08b8953782347dc477dea --- CMakeLists.txt | 2 -- packaging/nfc-plugin-emul.spec | 6 ++---- src/oem/oem_emul.c | 25 +++++++++++++++++-------- 3 files changed, 19 insertions(+), 14 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..531e400 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.23 Release: 0 Group: TO_BE/FILLED_IN License: Apache-2.0 @@ -32,8 +32,6 @@ make %{?jobs:-j%jobs} rm -rf %{buildroot} %make_install -install -D -m 0644 LICENSE.Apache-2.0 %{buildroot}/%{_datadir}/license/nfc-plugin-emul - mkdir -p %{buildroot}/usr/lib/udev/rules.d cp 98-nfc-plugin-emul.rules %{buildroot}/usr/lib/udev/rules.d/98-nfc-plugin-emul.rules @@ -42,7 +40,7 @@ cp 98-nfc-plugin-emul.rules %{buildroot}/usr/lib/udev/rules.d/98-nfc-plugin-emul %post -p /sbin/ldconfig %files +%license LICENSE.Apache-2.0 %defattr(-,root,root,-) /usr/lib/nfc/libnfc-plugin.so -%{_datadir}/license/nfc-plugin-emul /usr/lib/udev/rules.d/98-nfc-plugin-emul.rules diff --git a/src/oem/oem_emul.c b/src/oem/oem_emul.c index e7a223e..c4890b0 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) { @@ -1688,12 +1695,6 @@ static void emul_ReaderThread(void * pArg) DEBUG_MSG("epoll wait >>>>"); - if(emulMsg_poll_fd == -1 || emulMsg_file_fd == -1) - { - DEBUG_MSG("client is deinitialized. "); - condition = 0; - } - while((num_of_files = epoll_wait(emulMsg_poll_fd, emulMsg_poll_events, EPOLL_SIZE, -1)) == 0) { DEBUG_MSG("no data is changed "); } @@ -2201,6 +2202,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 +2275,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 +2286,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 +2295,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 +2306,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