summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2015-09-23 14:03:27 -0700
committerCedric BAIL <cedric@osg.samsung.com>2015-09-23 14:03:34 -0700
commit826998c15e0e24882ed8bea09c6f3252bf782f07 (patch)
treee9e83a04ed6df1139ff3a8e182256d81be0ffc63
parentfc454e467047662a31334f0e0e0886b63bc46d4f (diff)
ecore_exe: fix memory leak on realloc.
Summary: Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com> Reviewers: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D3091 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/ecore/ecore_exe_posix.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/ecore/ecore_exe_posix.c b/src/lib/ecore/ecore_exe_posix.c
index 1fd178312b..9e64cba1a4 100644
--- a/src/lib/ecore/ecore_exe_posix.c
+++ b/src/lib/ecore/ecore_exe_posix.c
@@ -1095,7 +1095,7 @@ _ecore_exe_data_generic_handler(void *data,
1095 if ((fd_handler) 1095 if ((fd_handler)
1096 && (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))) 1096 && (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)))
1097 { 1097 {
1098 unsigned char *inbuf; 1098 unsigned char *inbuf, *temp;
1099 int inbuf_num; 1099 int inbuf_num;
1100 1100
1101 /* Get any left over data from last time. */ 1101 /* Get any left over data from last time. */
@@ -1135,9 +1135,15 @@ _ecore_exe_data_generic_handler(void *data,
1135 } 1135 }
1136 if (num > 0) /* data got read. */ 1136 if (num > 0) /* data got read. */
1137 { 1137 {
1138 temp = inbuf;
1138 inbuf = realloc(inbuf, inbuf_num + num); 1139 inbuf = realloc(inbuf, inbuf_num + num);
1139 memcpy(inbuf + inbuf_num, buf, num); 1140 if (inbuf)
1140 inbuf_num += num; 1141 {
1142 memcpy(inbuf + inbuf_num, buf, num);
1143 inbuf_num += num;
1144 }
1145 else // realloc fails and returns NULL.
1146 inbuf = temp;
1141 } 1147 }
1142 else 1148 else
1143 { /* No more data to read. */ 1149 { /* No more data to read. */