Fix segment fault due to NULL pointer
authorArron Wang <arron.wang@intel.com>
Thu, 7 Mar 2013 06:38:14 +0000 (14:38 +0800)
committerJaekyun Lee <jkyun.lee@samsung.com>
Mon, 8 Apr 2013 07:49:05 +0000 (16:49 +0900)
Change-Id: Idd4e0cd7b5d2c6509f5c150af9bb9021d4f4811d

Program received signal SIGSEGV, Segmentation fault.
0xb77c36d4 in __memcpy_ssse3 () from /lib/libc.so.6
(gdb) bt
0  0xb77c36d4 in __memcpy_ssse3 () from /lib/libc.so.6
1  0xb57bdf2d in net_nfc_duplicate_target_info (origin=0xb84fe570,
    result=0xb7b5b414) at /usr/include/bits/string3.h:52
2  0xb7b55c32 in _nfc_response_handler ()
   from /usr/lib/libcapi-network-nfc.so.0
3  0xb57c9928 in net_nfc_client_dispatch_response (param=0xb8084580)
    at /usr/src/debug/nfc-manager-0.0.33/src/clientlib/net_nfc_client_dispatcher.c:453
4  0xb7854dc2 in g_idle_dispatch () from /usr/lib/libglib-2.0.so.0
5  0xb7857ddb in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
6  0xb79aad1b in _ecore_glib_select () from /usr/lib/libecore.so.1
7  0xb79a454d in _ecore_main_select () from /usr/lib/libecore.so.1
8  0xb79a5099 in _ecore_main_loop_iterate_internal ()
   from /usr/lib/libecore.so.1
9  0xb79a541f in ecore_main_loop_begin () from /usr/lib/libecore.so.1
10 0xb7ea14f8 in elm_run () from /usr/lib/libelementary.so.1
11 0xb58ee8ee in appcore_efl_main () from /usr/lib/libappcore-efl.so.1
12 0xb7d83c75 in app_efl_main () from /usr/lib/libcapi-appfw-application.so.0
13 0xb7fe879e in main ()

src/clientlib/net_nfc_client_target_info.c

index fb17acf..a0fb2aa 100755 (executable)
@@ -222,7 +222,7 @@ NET_NFC_EXPORT_API net_nfc_error_e net_nfc_duplicate_target_info(net_nfc_target_
                }
        }
 
-       if (handle->raw_data.length > 0)
+       if (handle->raw_data.buffer != NULL && handle->raw_data.length > 0)
        {
                net_nfc_util_alloc_data(&temp->raw_data, handle->raw_data.length);
                memcpy(temp->raw_data.buffer, handle->raw_data.buffer, temp->raw_data.length);