aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2014-12-01 18:16:37 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2014-12-01 18:16:37 +0000
commit23844fd7306763ee07f27acd6883fd47bc858ec3 (patch)
tree1d2badcdfd4c27a7c730c42dff28bb7ade429644 /gcc
parentc6760a13178f56f5aea081b0f88fa7695a9daf58 (diff)
downloadgcc-23844fd7306763ee07f27acd6883fd47bc858ec3.zip
gcc-23844fd7306763ee07f27acd6883fd47bc858ec3.tar.gz
gcc-23844fd7306763ee07f27acd6883fd47bc858ec3.tar.bz2
jit-builtins.c: Fix segfault on unsupported builtins
gcc/jit/ChangeLog: * jit-builtins.c (gcc::jit::recording::builtins_manager::get_builtin_function): Check for NULL return from make_builtin_function. (gcc::jit::recording::builtins_manager::make_builtin_function): Check for NULL return from get_type. From-SVN: r218239
Diffstat (limited to 'gcc')
-rw-r--r--gcc/jit/ChangeLog8
-rw-r--r--gcc/jit/jit-builtins.c13
2 files changed, 18 insertions, 3 deletions
diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog
index 36fcc76..042a6f0 100644
--- a/gcc/jit/ChangeLog
+++ b/gcc/jit/ChangeLog
@@ -1,5 +1,13 @@
2014-12-01 David Malcolm <dmalcolm@redhat.com>
+ * jit-builtins.c
+ (gcc::jit::recording::builtins_manager::get_builtin_function):
+ Check for NULL return from make_builtin_function.
+ (gcc::jit::recording::builtins_manager::make_builtin_function):
+ Check for NULL return from get_type.
+
+2014-12-01 David Malcolm <dmalcolm@redhat.com>
+
* jit-playback.c (gcc::jit::playback::context::compile): Move DSO
creation code into...
(gcc::jit::playback::context::convert_to_dso): New function.
diff --git a/gcc/jit/jit-builtins.c b/gcc/jit/jit-builtins.c
index 49d37d8..9063075 100644
--- a/gcc/jit/jit-builtins.c
+++ b/gcc/jit/jit-builtins.c
@@ -160,8 +160,12 @@ builtins_manager::get_builtin_function (const char *name)
the same id on a context give back the same object. */
if (!m_builtin_functions[builtin_id])
{
- m_builtin_functions[builtin_id] = make_builtin_function (builtin_id);
- m_ctxt->record (m_builtin_functions[builtin_id]);
+ function *fn = make_builtin_function (builtin_id);
+ if (fn)
+ {
+ m_builtin_functions[builtin_id] = fn;
+ m_ctxt->record (fn);
+ }
}
return m_builtin_functions[builtin_id];
@@ -174,7 +178,10 @@ builtins_manager::make_builtin_function (enum built_in_function builtin_id)
{
const struct builtin_data& bd = builtin_data[builtin_id];
enum jit_builtin_type type_id = bd.type;
- function_type *func_type = get_type (type_id)->as_a_function_type ();
+ type *t = get_type (type_id);
+ if (!t)
+ return NULL;
+ function_type *func_type = t->as_a_function_type ();
if (!func_type)
return NULL;