summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-09-15 07:44:58 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-09-15 07:44:58 +0900
commitdc137aba436e235995c0760694aea89d663e15e7 (patch)
tree557336d6569c3a1e13eeec39179ec893f987c63f /src/lib
parent0f08ee686ecf91d7815f35ddc8481fd7d2936988 (diff)
ecore exe - fix fix malloc fail handling
for both ecore_exe_win32.c and ecore_exe_posix.c when the rare case (basically almost never) that malloc fails for the exe read/err buffers also set the data size to 0 so it doesn't lie with a NULL ptr for data. @fix
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore/ecore_exe_posix.c12
-rw-r--r--src/lib/ecore/ecore_exe_win32.c16
2 files changed, 18 insertions, 10 deletions
diff --git a/src/lib/ecore/ecore_exe_posix.c b/src/lib/ecore/ecore_exe_posix.c
index 46a97d1..2a240a2 100644
--- a/src/lib/ecore/ecore_exe_posix.c
+++ b/src/lib/ecore/ecore_exe_posix.c
@@ -711,20 +711,24 @@ _impl_ecore_exe_event_data_get(Ecore_Exe *obj,
711 exe->read_data_size = i - last; 711 exe->read_data_size = i - last;
712 exe->read_data_buf = malloc(exe->read_data_size); 712 exe->read_data_buf = malloc(exe->read_data_size);
713 if (exe->read_data_buf) 713 if (exe->read_data_buf)
714 memcpy(exe->read_data_buf, c, exe->read_data_size);
715 else
714 { 716 {
715 memcpy(exe->read_data_buf, c, exe->read_data_size); 717 exe->read_data_size = 0;
718 ERR("Out of memory in allocating exe pipe data");
716 } 719 }
717 else ERR("Out of memory in allocating exe pipe data");
718 } 720 }
719 else 721 else
720 { 722 {
721 exe->error_data_size = i - last; 723 exe->error_data_size = i - last;
722 exe->error_data_buf = malloc(exe->error_data_size); 724 exe->error_data_buf = malloc(exe->error_data_size);
723 if (exe->error_data_buf) 725 if (exe->error_data_buf)
726 memcpy(exe->error_data_buf, c, exe->error_data_size);
727 else
724 { 728 {
725 memcpy(exe->error_data_buf, c, exe->error_data_size); 729 exe->error_data_size = 0;
730 ERR("Out of memory in allocating exe pipe data");
726 } 731 }
727 else ERR("Out of memory in allocating exe pipe data");
728 } 732 }
729 } 733 }
730 if (count == 0) /* No lines to send, cancel the event. */ 734 if (count == 0) /* No lines to send, cancel the event. */
diff --git a/src/lib/ecore/ecore_exe_win32.c b/src/lib/ecore/ecore_exe_win32.c
index e437b5a..80a4e70 100644
--- a/src/lib/ecore/ecore_exe_win32.c
+++ b/src/lib/ecore/ecore_exe_win32.c
@@ -664,23 +664,27 @@ _impl_ecore_exe_event_data_get(Ecore_Exe *obj,
664 if (count != 0) e->size = last; 664 if (count != 0) e->size = last;
665 if (flags & ECORE_EXE_PIPE_READ) 665 if (flags & ECORE_EXE_PIPE_READ)
666 { 666 {
667 exe->pipe_read.data_size = i - last;
667 exe->pipe_read.data_buf = malloc(exe->pipe_read.data_size); 668 exe->pipe_read.data_buf = malloc(exe->pipe_read.data_size);
668 if (exe->pipe_read.data_buf) 669 if (exe->pipe_read.data_buf)
670 memcpy(exe->pipe_read.data_buf, c, exe->pipe_read.data_size);
671 else
669 { 672 {
670 exe->pipe_read.data_size = i - last; 673 exe->pipe_read.data_size = 0;
671 memcpy(exe->pipe_read.data_buf, c, exe->pipe_read.data_size); 674 ERR("Out of memory in allocating exe pipe data");
672 } 675 }
673 else ERR("Out of memory in allocating exe pipe data");
674 } 676 }
675 else 677 else
676 { 678 {
679 exe->pipe_error.data_size = i - last;
677 exe->pipe_error.data_buf = malloc(exe->pipe_error.data_size); 680 exe->pipe_error.data_buf = malloc(exe->pipe_error.data_size);
678 if (exe->pipe_error.data_buf) 681 if (exe->pipe_error.data_buf)
682 memcpy(exe->pipe_error.data_buf, c, exe->pipe_error.data_size);
683 else
679 { 684 {
680 exe->pipe_error.data_size = i - last; 685 exe->pipe_error.data_size = 0;
681 memcpy(exe->pipe_error.data_buf, c, exe->pipe_error.data_size); 686 ERR("Out of memory in allocating exe pipe data");
682 } 687 }
683 else ERR("Out of memory in allocating exe pipe data");
684 } 688 }
685 } 689 }
686 if (count == 0) /* No lines to send, cancel the event. */ 690 if (count == 0) /* No lines to send, cancel the event. */