summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-07-24 16:57:22 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-07-24 16:57:22 +0900
commit829d0bc3f993a0346171844486f1d021465c4055 (patch)
tree8f937be114e94f9ec34bbb5220d305592501aa33
parentb47cbdcb65b2cc9d4ec3456a922842d26b5b5564 (diff)
downloadefl-829d0bc3f993a0346171844486f1d021465c4055.tar.gz
ecore win32 exe handling - check realloc and malloc returns
handle out of memory errors better @fix
-rw-r--r--src/lib/ecore/ecore_exe_win32.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/lib/ecore/ecore_exe_win32.c b/src/lib/ecore/ecore_exe_win32.c
index 33854f89be..e437b5aff6 100644
--- a/src/lib/ecore/ecore_exe_win32.c
+++ b/src/lib/ecore/ecore_exe_win32.c
@@ -210,6 +210,7 @@ _ecore_exe_win32_io_poll_notify(void *data EINA_UNUSED,
exe->pipe_read.data_buf = b;
exe->pipe_read.data_size += trep->buf_size;
}
+ else ERR("Out of memory in reading exe pipe data");
}
event_data = ecore_exe_event_data_get(obj, ECORE_EXE_PIPE_READ);
if (event_data)
@@ -239,6 +240,7 @@ _ecore_exe_win32_io_poll_notify(void *data EINA_UNUSED,
exe->pipe_error.data_buf = b;
exe->pipe_error.data_size += trep->buf_size;
}
+ else ERR("Out of memory in reading exe pipe data");
}
event_data = ecore_exe_event_data_get(obj, ECORE_EXE_PIPE_ERROR);
if (event_data)
@@ -634,10 +636,17 @@ _impl_ecore_exe_event_data_get(Ecore_Exe *obj,
if (count >= max)
{
+ Ecore_Exe_Event_Data_Line *lines;
+
max += 10;
- e->lines = realloc
- (e->lines,
- sizeof(Ecore_Exe_Event_Data_Line) * (max + 1));
+ lines = realloc (e->lines,
+ sizeof(Ecore_Exe_Event_Data_Line) * (max + 1));
+ if (lines) e->lines = lines;
+ else
+ {
+ ERR("Out of memory in allocating exe lines");
+ break;
+ }
}
if ((i >= 1) && (inbuf[i - 1] == '\r')) end = i - 1;
@@ -655,15 +664,23 @@ _impl_ecore_exe_event_data_get(Ecore_Exe *obj,
if (count != 0) e->size = last;
if (flags & ECORE_EXE_PIPE_READ)
{
- exe->pipe_read.data_size = i - last;
exe->pipe_read.data_buf = malloc(exe->pipe_read.data_size);
- memcpy(exe->pipe_read.data_buf, c, exe->pipe_read.data_size);
+ if (exe->pipe_read.data_buf)
+ {
+ exe->pipe_read.data_size = i - last;
+ memcpy(exe->pipe_read.data_buf, c, exe->pipe_read.data_size);
+ }
+ else ERR("Out of memory in allocating exe pipe data");
}
else
{
- exe->pipe_error.data_size = i - last;
exe->pipe_error.data_buf = malloc(exe->pipe_error.data_size);
- memcpy(exe->pipe_error.data_buf, c, exe->pipe_error.data_size);
+ if (exe->pipe_error.data_buf)
+ {
+ exe->pipe_error.data_size = i - last;
+ memcpy(exe->pipe_error.data_buf, c, exe->pipe_error.data_size);
+ }
+ else ERR("Out of memory in allocating exe pipe data");
}
}
if (count == 0) /* No lines to send, cancel the event. */