summaryrefslogtreecommitdiff
path: root/src/lib/ecore
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 /src/lib/ecore
parentb47cbdcb65b2cc9d4ec3456a922842d26b5b5564 (diff)
ecore win32 exe handling - check realloc and malloc returns
handle out of memory errors better @fix
Diffstat (limited to 'src/lib/ecore')
-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,
210 exe->pipe_read.data_buf = b; 210 exe->pipe_read.data_buf = b;
211 exe->pipe_read.data_size += trep->buf_size; 211 exe->pipe_read.data_size += trep->buf_size;
212 } 212 }
213 else ERR("Out of memory in reading exe pipe data");
213 } 214 }
214 event_data = ecore_exe_event_data_get(obj, ECORE_EXE_PIPE_READ); 215 event_data = ecore_exe_event_data_get(obj, ECORE_EXE_PIPE_READ);
215 if (event_data) 216 if (event_data)
@@ -239,6 +240,7 @@ _ecore_exe_win32_io_poll_notify(void *data EINA_UNUSED,
239 exe->pipe_error.data_buf = b; 240 exe->pipe_error.data_buf = b;
240 exe->pipe_error.data_size += trep->buf_size; 241 exe->pipe_error.data_size += trep->buf_size;
241 } 242 }
243 else ERR("Out of memory in reading exe pipe data");
242 } 244 }
243 event_data = ecore_exe_event_data_get(obj, ECORE_EXE_PIPE_ERROR); 245 event_data = ecore_exe_event_data_get(obj, ECORE_EXE_PIPE_ERROR);
244 if (event_data) 246 if (event_data)
@@ -634,10 +636,17 @@ _impl_ecore_exe_event_data_get(Ecore_Exe *obj,
634 636
635 if (count >= max) 637 if (count >= max)
636 { 638 {
639 Ecore_Exe_Event_Data_Line *lines;
640
637 max += 10; 641 max += 10;
638 e->lines = realloc 642 lines = realloc (e->lines,
639 (e->lines, 643 sizeof(Ecore_Exe_Event_Data_Line) * (max + 1));
640 sizeof(Ecore_Exe_Event_Data_Line) * (max + 1)); 644 if (lines) e->lines = lines;
645 else
646 {
647 ERR("Out of memory in allocating exe lines");
648 break;
649 }
641 } 650 }
642 651
643 if ((i >= 1) && (inbuf[i - 1] == '\r')) end = i - 1; 652 if ((i >= 1) && (inbuf[i - 1] == '\r')) end = i - 1;
@@ -655,15 +664,23 @@ _impl_ecore_exe_event_data_get(Ecore_Exe *obj,
655 if (count != 0) e->size = last; 664 if (count != 0) e->size = last;
656 if (flags & ECORE_EXE_PIPE_READ) 665 if (flags & ECORE_EXE_PIPE_READ)
657 { 666 {
658 exe->pipe_read.data_size = i - last;
659 exe->pipe_read.data_buf = malloc(exe->pipe_read.data_size); 667 exe->pipe_read.data_buf = malloc(exe->pipe_read.data_size);
660 memcpy(exe->pipe_read.data_buf, c, exe->pipe_read.data_size); 668 if (exe->pipe_read.data_buf)
669 {
670 exe->pipe_read.data_size = i - last;
671 memcpy(exe->pipe_read.data_buf, c, exe->pipe_read.data_size);
672 }
673 else ERR("Out of memory in allocating exe pipe data");
661 } 674 }
662 else 675 else
663 { 676 {
664 exe->pipe_error.data_size = i - last;
665 exe->pipe_error.data_buf = malloc(exe->pipe_error.data_size); 677 exe->pipe_error.data_buf = malloc(exe->pipe_error.data_size);
666 memcpy(exe->pipe_error.data_buf, c, exe->pipe_error.data_size); 678 if (exe->pipe_error.data_buf)
679 {
680 exe->pipe_error.data_size = i - last;
681 memcpy(exe->pipe_error.data_buf, c, exe->pipe_error.data_size);
682 }
683 else ERR("Out of memory in allocating exe pipe data");
667 } 684 }
668 } 685 }
669 if (count == 0) /* No lines to send, cancel the event. */ 686 if (count == 0) /* No lines to send, cancel the event. */