summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifeng Li <tomli@tomli.me>2023-02-20 10:19:19 +0000
committerWill Estes <westes@users.noreply.github.com>2023-03-09 14:45:08 -0500
commita57e165cc50265e6ca1f6e12313e3154c6a6f96c (patch)
treecc0f0d10189371eefa12d86f707df177507a3086
parent74e8c880fc043b765a5b2ea7ccdfee252d38beb4 (diff)
downloadflex-git-a57e165cc50265e6ca1f6e12313e3154c6a6f96c.tar.gz
Fix #539 crash on Apple M1 by casting 0 to (char *) explicitly
Currently, when the NULL-terminated variadic function filter_create_ext() is invoked, the value "0" is passed as the last argument to act as a terminator. However, this is an integer value, which is incompatible with the pointer data type expected by filter_create_ext(). This is undefined behavior in C, correct operation is not guaranteed. In fact, it causes flex to crash on Apple M1 when GCC is used - the loop is not terminated when it should, instead, it keeps running, corrupting the argument list for invoking m4. As a result, it creates the following error: > flex: fatal internal error, exec of gm4 failed This commit fixes the problem by explicitly casting the value 0 to the correct pointer type (char *). Signed-off-by: Yifeng Li <tomli@tomli.me>
-rw-r--r--src/main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index c4e6849..eb2c09f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -295,7 +295,7 @@ void initialize_output_filters(void)
if ( !(m4 = getenv("M4"))) {
m4 = M4;
}
- filter_create_ext(output_chain, m4, "-P", 0);
+ filter_create_ext(output_chain, m4, "-P", (char *) 0);
filter_create_int(output_chain, filter_fix_linedirs, NULL);
/* For debugging, only run the requested number of filters. */