summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2015-10-08 12:26:55 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-10-09 10:00:32 +0200
commit54b47a78ebe35f5f35d83b1aa774354b7d69604f (patch)
tree1a44dba06f16b22f0a9bf0dfa64c0dec0dbf198c /src/examples
parent01e42f86abb5d060437af68fab5c8b5afe267d08 (diff)
ecore_con: preventing possible NULL pointer dereference.
Summary: Checking if client is NULL before freeing is not of much use. If it is NULL, it would have crashed before when it was dereferenced in printf. So checking NULL before dereferencing. Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com> Reviewers: cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D3151 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/ecore/ecore_con_server_simple_example.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/examples/ecore/ecore_con_server_simple_example.c b/src/examples/ecore/ecore_con_server_simple_example.c
index 3c46ea2965..e61275785c 100644
--- a/src/examples/ecore/ecore_con_server_simple_example.c
+++ b/src/examples/ecore/ecore_con_server_simple_example.c
@@ -53,13 +53,14 @@ _del(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Client_Del *e
53 client = ecore_con_client_data_get(ev->client); 53 client = ecore_con_client_data_get(ev->client);
54 54
55 printf("Lost client with ip %s!\n", ecore_con_client_ip_get(ev->client)); 55 printf("Lost client with ip %s!\n", ecore_con_client_ip_get(ev->client));
56 printf("Total data received from this client: %d\n", client->sdata); 56 if (client)
57 {
58 printf("Total data received from this client: %d\n", client->sdata);
59 free(client);
60 }
57 printf("Client was connected for %0.3f seconds.\n", 61 printf("Client was connected for %0.3f seconds.\n",
58 ecore_con_client_uptime_get(ev->client)); 62 ecore_con_client_uptime_get(ev->client));
59 63
60 if (client)
61 free(client);
62
63 ecore_con_client_del(ev->client); 64 ecore_con_client_del(ev->client);
64 65
65 return ECORE_CALLBACK_RENEW; 66 return ECORE_CALLBACK_RENEW;