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>
This commit is contained in:
Srivardhan Hebbar 2015-09-23 12:42:18 -07:00 committed by Cedric BAIL
parent d595149178
commit c79d822f53
1 changed files with 5 additions and 4 deletions

View File

@ -58,13 +58,14 @@ _del(void *data EINA_UNUSED, int type EINA_UNUSED, Ecore_Con_Event_Client_Del *e
client = ecore_con_client_data_get(ev->client);
printf("Lost client with ip %s!\n", ecore_con_client_ip_get(ev->client));
printf("Total data received from this client: %d\n", client->sdata);
if (client)
{
printf("Total data received from this client: %d\n", client->sdata);
free(client);
}
printf("Client was connected for %0.3f seconds.\n",
ecore_con_client_uptime_get(ev->client));
if (client)
free(client);
ecore_con_client_del(ev->client);
return ECORE_CALLBACK_RENEW;