Fix crash accessing builtins in sanitizer.def and after (PR jit/82174)
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 14 Sep 2017 19:30:26 +0000 (19:30 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Thu, 14 Sep 2017 19:30:26 +0000 (19:30 +0000)
commit595ced60609a353b91face2f87b6f7abe3eaf28c
tree1552625327e2fe8d8b3a6495510f865444982ff7
parent44e13e607f63ef73c75cd64b041f24b0eeafd992
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
gcc/jit/ChangeLog
gcc/jit/jit-builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/jit.dg/test-error-gcc_jit_context_get_builtin_function-unknown-builtin.c [new file with mode: 0644]