aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2017-09-14 19:30:26 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2017-09-14 19:30:26 +0000
commit595ced60609a353b91face2f87b6f7abe3eaf28c (patch)
tree1552625327e2fe8d8b3a6495510f865444982ff7 /gcc/jit
parent44e13e607f63ef73c75cd64b041f24b0eeafd992 (diff)
downloadgcc-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/jit')
-rw-r--r--gcc/jit/ChangeLog6
-rw-r--r--gcc/jit/jit-builtins.c5
2 files changed, 10 insertions, 1 deletions
diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog
index d06722c..63d8b06 100644
--- a/gcc/jit/ChangeLog
+++ b/gcc/jit/ChangeLog
@@ -1,3 +1,9 @@
+2017-09-14 David Malcolm <dmalcolm@redhat.com>
+
+ PR jit/82174
+ * jit-builtins.c (matches_builtin): Ignore entries with a NULL
+ name.
+
2017-08-18 David Malcolm <dmalcolm@redhat.com>
PR tree-optimization/46805
diff --git a/gcc/jit/jit-builtins.c b/gcc/jit/jit-builtins.c
index 7840915..35c4db0 100644
--- a/gcc/jit/jit-builtins.c
+++ b/gcc/jit/jit-builtins.c
@@ -68,7 +68,10 @@ matches_builtin (const char *in_name,
const struct builtin_data& bd)
{
const bool debug = 0;
- gcc_assert (bd.name);
+
+ /* Ignore entries with a NULL name. */
+ if (!bd.name)
+ return false;
if (debug)
fprintf (stderr, "seen builtin: %s\n", bd.name);