cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=54b47a78ebe35f5f35d83b1aa774354b7d69604f

commit 54b47a78ebe35f5f35d83b1aa774354b7d69604f
Author: Srivardhan Hebbar <sri.heb...@samsung.com>
Date:   Thu Oct 8 12:26:55 2015 +0200

    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.heb...@samsung.com>
    
    Reviewers: cedric
    
    Reviewed By: cedric
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D3151
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/examples/ecore/ecore_con_server_simple_example.c | 9 +++++----
 1 file 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 3c46ea2..e612757 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
    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;

-- 


Reply via email to