raster pushed a commit to branch master.

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

commit b47cbdcb65b2cc9d4ec3456a922842d26b5b5564
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Mon Jul 24 14:10:17 2017 +0900

    ecore_exe - handle realloc failures by complaining and rolling back
    
    @fix
---
 src/lib/ecore/ecore_exe_posix.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/lib/ecore/ecore_exe_posix.c b/src/lib/ecore/ecore_exe_posix.c
index f30ff7a8f5..9624f80be4 100644
--- a/src/lib/ecore/ecore_exe_posix.c
+++ b/src/lib/ecore/ecore_exe_posix.c
@@ -668,9 +668,17 @@ _impl_ecore_exe_event_data_get(Ecore_Exe      *obj,
             {
                if (count >= max)
                {
+                  Ecore_Exe_Event_Data_Line *lines;
+
                   /* In testing, the lines seem to arrive in batches of 500 to 
1000 lines at most, roughly speaking. */
                    max += 10; /* FIXME: Maybe keep track of the largest number 
of lines ever sent, and add half that many instead of 10. */
-                   e->lines = realloc(e->lines, 
sizeof(Ecore_Exe_Event_Data_Line) * (max + 1)); /* Allow room for the NULL 
termination. */
+                   lines = realloc(e->lines, sizeof(Ecore_Exe_Event_Data_Line) 
* (max + 1)); /* Allow room for the NULL termination. */
+                   if (!lines)
+                   {
+                      ERR("Out of memory adding exe data lines to event");
+                      break;
+                   }
+                   e->lines = lines;
                }
                /* raster said to leave the line endings as line endings, 
however -
                 * This is line buffered mode, we are not dealing with binary 
here, but lines.
@@ -1149,7 +1157,10 @@ _ecore_exe_data_generic_handler(void             *data,
                  inbuf_num += num;
               }
             else // realloc fails and returns NULL.
-               inbuf = temp;
+              {
+                 ERR("Out of memory in exe generic data handler");
+                 inbuf = temp;
+              }
          }
          else
          { /* No more data to read. */

-- 


Reply via email to