ecore/ecore_exe - Don't free the event data while we use it.
authorRafael Antognolli <antognolli@gmail.com>
Mon, 29 Aug 2011 21:20:26 +0000 (21:20 +0000)
committerRafael Antognolli <antognolli@gmail.com>
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.

SVN revision: 62970

legacy/ecore/src/lib/ecore/ecore_exe.c

index 12027bfedb36992f3d2637dc1feb54eed3826b1a..07407ef162275898ec026f58169061ea17bdb07a 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;
+               }
           }
      }