Fix crash accessing builtins in sanitizer.def and after (PR jit/82174)
commit4bb14839b20981bb3a7d5df9f77b452d8f59c9b3
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Sep 2017 19:30:26 +0000 (14 19:30 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Sep 2017 19:30:26 +0000 (14 19:30 +0000)
tree1552625327e2fe8d8b3a6495510f865444982ff7
parent17e8811c445788b919b16486c833f12eff5138d3
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@252769 138bc75d-0d04-0410-961f-82ee72b054a4
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]