diff options
author | David Malcolm <dmalcolm@redhat.com> | 2014-12-01 15:58:11 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2014-12-01 15:58:11 +0000 |
commit | c985705ae91243bdabd4d828365017ef264bbd91 (patch) | |
tree | b68a1a2418f0312b0d2fcf8079fb1e32fefd48aa /gcc/jit/jit-playback.c | |
parent | 81f263694d6451a17f7d6d3753fae85a01243619 (diff) | |
download | gcc-c985705ae91243bdabd4d828365017ef264bbd91.zip gcc-c985705ae91243bdabd4d828365017ef264bbd91.tar.gz gcc-c985705ae91243bdabd4d828365017ef264bbd91.tar.bz2 |
PR jit/63969: Fix segfault in error-handling when driver isn't found
gcc/jit/ChangeLog:
PR jit/63969
* jit-playback.c: Ensure that ctxt_progname is non-NULL.
gcc/testsuite/ChangeLog:
PR jit/63969
* jit.dg/harness.h (CHECK_STRING_STARTS_WITH): New.
(check_string_starts_with): New.
* jit.dg/test-error-pr63969-missing-driver.c: New.
From-SVN: r218226
Diffstat (limited to 'gcc/jit/jit-playback.c')
-rw-r--r-- | gcc/jit/jit-playback.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c index 8fdfa29..584a8e6 100644 --- a/gcc/jit/jit-playback.c +++ b/gcc/jit/jit-playback.c @@ -1571,9 +1571,11 @@ compile () /* Pass in user-provided program name as argv0, if any, so that it makes it into GCC's "progname" global, used in various diagnostics. */ ctxt_progname = get_str_option (GCC_JIT_STR_OPTION_PROGNAME); - fake_args[0] = - (ctxt_progname ? ctxt_progname : "libgccjit.so"); + if (!ctxt_progname) + ctxt_progname = "libgccjit.so"; + + fake_args[0] = ctxt_progname; fake_args[1] = m_path_c_file; num_args = 2; @@ -1689,6 +1691,9 @@ compile () /* pex argv arrays are NULL-terminated. */ argv[6] = NULL; + /* pex_one's error-handling requires pname to be non-NULL. */ + gcc_assert (ctxt_progname); + errmsg = pex_one (PEX_SEARCH, /* int flags, */ gcc_driver_name, const_cast<char * const *> (argv), |