From 53ac0c5a36ce514eb98a90193e69c1fc40d1ffbe Mon Sep 17 00:00:00 2001 From: David Schleef Date: Mon, 28 Jun 2010 13:43:31 -0700 Subject: [PATCH] Fix segfaults if no targets are available --- orc/orccompiler.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/orc/orccompiler.c b/orc/orccompiler.c index 0a27643..ca8ed3d 100644 --- a/orc/orccompiler.c +++ b/orc/orccompiler.c @@ -150,7 +150,11 @@ orc_program_compile_for_target (OrcProgram *program, OrcTarget *target) { unsigned int flags; - flags = target->get_default_flags (); + if (target) { + flags = target->get_default_flags (); + } else { + flags = 0; + } return orc_program_compile_full (program, target, flags); } @@ -188,6 +192,13 @@ orc_program_compile_full (OrcProgram *program, OrcTarget *target, if (program->backup_func && _orc_compiler_flag_backup) { ORC_COMPILER_ERROR(compiler, "Compilation disabled"); + compiler->result = ORC_COMPILE_RESULT_UNKNOWN_COMPILE; + goto error; + } + + if (target == NULL) { + ORC_COMPILER_ERROR(compiler, "No target given"); + compiler->result = ORC_COMPILE_RESULT_UNKNOWN_COMPILE; goto error; } -- 2.7.4