Check whether we actually want to alloc data
authorenglebass <englebass@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 5 Nov 2010 13:11:52 +0000 (13:11 +0000)
committerenglebass <englebass@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 5 Nov 2010 13:11:52 +0000 (13:11 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@54179 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore_con/ecore_con.c

index 3f24ab5..b947639 100644 (file)
@@ -1774,14 +1774,18 @@ _ecore_con_cl_read(Ecore_Con_Server *svr)
 
       svr->event_count++;
       e->server = svr;
-      e->data = malloc(num);
-      if (!e->data)
+      e->data = NULL;
+      if (num > 0)
         {
-           ERR("alloc!");
-           free(e);
-           return;
+           e->data = malloc(num);
+           if (!e->data)
+             {
+                ERR("alloc!");
+                free(e);
+                return;
+             }
+           memcpy(e->data, buf, num);
         }
-      memcpy(e->data, buf, num);
       e->size = num;
       ecore_event_add(ECORE_CON_EVENT_SERVER_DATA, e,
                       _ecore_con_event_server_data_free, NULL);
@@ -2106,14 +2110,18 @@ _ecore_con_svr_cl_read(Ecore_Con_Client *cl)
         cl->event_count++;
         _ecore_con_cl_timer_update(cl);
         e->client = cl;
-        e->data = malloc(num);
-        if (!e->data)
+        e->data = NULL;
+        if (num > 0)
           {
-             free(e);
-             ERR("alloc!");
-             return;
+             e->data = malloc(num);
+             if (!e->data)
+               {
+                  ERR("alloc!");
+                  free(e);
+                  return;
+               }
+             memcpy(e->data, buf, num);
           }
-        memcpy(e->data, buf, num);
         e->size = num;
         ecore_event_add(ECORE_CON_EVENT_CLIENT_DATA, e,
                         _ecore_con_event_client_data_free, NULL);