ecore/ecore_exe - Don't free the event data while we use it.
authorantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 29 Aug 2011 21:20:26 +0000 (21:20 +0000)
committerantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 29 Aug 2011 21:20:26 +0000 (21:20 +0000)
Since we are memcpying it to a new allocated memory, we can only free it after
finishing doing that.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@62970 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore/ecore_exe.c

index 12027bf..07407ef 100644 (file)
@@ -915,19 +915,9 @@ ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags)
                        count++;
                     }
                }
-             if (count == 0)        /* No lines to send, cancel the event. */
-               {
-                  _ecore_exe_event_exe_data_free(NULL, e);
-                  e = NULL;
-               }
-             else                /* NULL terminate the array, so that people know where the end is. */
-               {
-                  e->lines[count].line = NULL;
-                  e->lines[count].size = 0;
-               }
              if (i > last)        /* Partial line left over, save it for next time. */
                {
-                  if (e) e->size = last;
+                  if (count != 0) e->size = last;
                   if (flags & ECORE_EXE_PIPE_READ)
                     {
                        exe->read_data_size = i - last;
@@ -941,6 +931,16 @@ ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags)
                        memcpy(exe->error_data_buf, c, exe->error_data_size);
                     }
                }
+             if (count == 0)        /* No lines to send, cancel the event. */
+               {
+                  _ecore_exe_event_exe_data_free(NULL, e);
+                  e = NULL;
+               }
+             else                /* NULL terminate the array, so that people know where the end is. */
+               {
+                  e->lines[count].line = NULL;
+                  e->lines[count].size = 0;
+               }
           }
      }