diff options
author | David Malcolm <dmalcolm@redhat.com> | 2017-09-14 19:30:26 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2017-09-14 19:30:26 +0000 |
commit | 595ced60609a353b91face2f87b6f7abe3eaf28c (patch) | |
tree | 1552625327e2fe8d8b3a6495510f865444982ff7 /gcc/testsuite/jit.dg | |
parent | 44e13e607f63ef73c75cd64b041f24b0eeafd992 (diff) | |
download | gcc-595ced60609a353b91face2f87b6f7abe3eaf28c.zip gcc-595ced60609a353b91face2f87b6f7abe3eaf28c.tar.gz gcc-595ced60609a353b91face2f87b6f7abe3eaf28c.tar.bz2 |
Fix crash accessing builtins in sanitizer.def and after (PR jit/82174)
Calls to gcc_jit_context_get_builtin_function that accessed builtins
in sanitizer.def and after (or failed to match any builtin) led to
a crash accessing a NULL builtin name.
The entries with the NULL name came from these lines in sanitizer.def:
/* This has to come before all the sanitizer builtins. */
DEF_BUILTIN_STUB(BEGIN_SANITIZER_BUILTINS, (const char *)0)
[...snip...]
/* This has to come after all the sanitizer builtins. */
DEF_BUILTIN_STUB(END_SANITIZER_BUILTINS, (const char *)0)
This patch updates jit-builtins.c to cope with such entries, fixing the
crash.
gcc/jit/ChangeLog:
PR jit/82174
* jit-builtins.c (matches_builtin): Ignore entries with a NULL
name.
gcc/testsuite/ChangeLog:
PR jit/82174
* jit.dg/test-error-gcc_jit_context_get_builtin_function-unknown-builtin.c:
New test case.
From-SVN: r252769
Diffstat (limited to 'gcc/testsuite/jit.dg')
-rw-r--r-- | gcc/testsuite/jit.dg/test-error-gcc_jit_context_get_builtin_function-unknown-builtin.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/testsuite/jit.dg/test-error-gcc_jit_context_get_builtin_function-unknown-builtin.c b/gcc/testsuite/jit.dg/test-error-gcc_jit_context_get_builtin_function-unknown-builtin.c new file mode 100644 index 0000000..b1e389c --- /dev/null +++ b/gcc/testsuite/jit.dg/test-error-gcc_jit_context_get_builtin_function-unknown-builtin.c @@ -0,0 +1,22 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "libgccjit.h" + +#include "harness.h" + +void +create_code (gcc_jit_context *ctxt, void *user_data) +{ + gcc_jit_context_get_builtin_function (ctxt, + "this_is_not_a_builtin"); +} + +void +verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) +{ + CHECK_VALUE (result, NULL); + + CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), + "builtin \"this_is_not_a_builtin\" not found"); +} |