summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2015-09-23 12:42:18 -0700
committerCedric BAIL <cedric@osg.samsung.com>2015-09-23 12:42:22 -0700
commitc79d822f53985821b245e134b568f4017668a462 (patch)
tree79692b4a4c22a1d1e3f2c551343e217dbeb6d85a
parentd595149178f8d81a9c24883541b09a912e3c15a8 (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 Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D3088 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/examples/ecore/ecore_con_server_http_example.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/examples/ecore/ecore_con_server_http_example.c b/src/examples/ecore/ecore_con_server_http_example.c
index 1269b73536..b0dfc6310e 100644
--- a/src/examples/ecore/ecore_con_server_http_example.c
+++ b/src/examples/ecore/ecore_con_server_http_example.c
@@ -58,13 +58,14 @@ _del(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Client_Del *e
58 client = ecore_con_client_data_get(ev->client); 58 client = ecore_con_client_data_get(ev->client);
59 59
60 printf("Lost client with ip %s!\n", ecore_con_client_ip_get(ev->client)); 60 printf("Lost client with ip %s!\n", ecore_con_client_ip_get(ev->client));
61 printf("Total data received from this client: %d\n", client->sdata); 61 if (client)
62 {
63 printf("Total data received from this client: %d\n", client->sdata);
64 free(client);
65 }
62 printf("Client was connected for %0.3f seconds.\n", 66 printf("Client was connected for %0.3f seconds.\n",
63 ecore_con_client_uptime_get(ev->client)); 67 ecore_con_client_uptime_get(ev->client));
64 68
65 if (client)
66 free(client);
67
68 ecore_con_client_del(ev->client); 69 ecore_con_client_del(ev->client);
69 70
70 return ECORE_CALLBACK_RENEW; 71 return ECORE_CALLBACK_RENEW;