summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean@guyomarch.bzh>2016-10-05 12:00:38 +0200
committerJean Guyomarc'h <jean@guyomarch.bzh>2016-10-14 18:26:30 +0200
commitd3b99e336589d9b2be031ad40cebf8372e01631a (patch)
treed827145a3826aaeb4b528deca89145abed1c0b76
parenta9e6bac27ccb3a94f71ebf96b009e5812a82cf81 (diff)
downloadefl-devs/jayji/efl-1.18.tar.gz
epp: fix memory corruption when using #warning and #errordevs/jayji/efl-1.18
The epp instructions #warning and #error would led to a segmentation fault (invalid free) because the malloced buffer's base pointer was moved. @fix
-rw-r--r--src/bin/edje/epp/cpplib.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/bin/edje/epp/cpplib.c b/src/bin/edje/epp/cpplib.c
index 5fb73756d2..a60aa84717 100644
--- a/src/bin/edje/epp/cpplib.c
+++ b/src/bin/edje/epp/cpplib.c
@@ -3904,11 +3904,12 @@ do_error(cpp_reader * pfile, struct directive *keyword EINA_UNUSED,
{
int length = limit - buf;
unsigned char *copy = (unsigned char *)xmalloc(length + 1);
+ unsigned char *msg = copy;
memcpy(copy, buf, length);
copy[length] = 0;
- SKIP_WHITE_SPACE(copy);
- cpp_error(pfile, "#error %s", copy);
+ SKIP_WHITE_SPACE(msg);
+ cpp_error(pfile, "#error %s", msg);
free(copy);
return 0;
}
@@ -3925,11 +3926,12 @@ do_warning(cpp_reader * pfile, struct directive *keyword EINA_UNUSED,
{
int length = limit - buf;
unsigned char *copy = (unsigned char *)xmalloc(length + 1);
+ unsigned char *msg = copy;
memcpy(copy, buf, length);
copy[length] = 0;
- SKIP_WHITE_SPACE(copy);
- cpp_warning(pfile, "#warning %s", copy);
+ SKIP_WHITE_SPACE(msg);
+ cpp_warning(pfile, "#warning %s", msg);
free(copy);
return 0;
}