diff options
author | David Malcolm <dmalcolm@redhat.com> | 2014-12-19 20:11:16 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2014-12-19 20:11:16 +0000 |
commit | 5afd44e33b13b922760a41580020f941dbdd473e (patch) | |
tree | 2b78dbe689abc0b585bd0a406ee3b372652a2bf4 | |
parent | 3eb239f48bf0ca6ed149a3f0ff114f55ecaad978 (diff) | |
download | gcc-5afd44e33b13b922760a41580020f941dbdd473e.zip gcc-5afd44e33b13b922760a41580020f941dbdd473e.tar.gz gcc-5afd44e33b13b922760a41580020f941dbdd473e.tar.bz2 |
Fix issue with string options and nested gcc_jit_contexts
gcc/jit/ChangeLog:
* jit-recording.c (gcc::jit::recording::context::context): When
copying string options from a parent context, take a copy of the
underlying buffers, rather than simply copying the pointer.
From-SVN: r218972
-rw-r--r-- | gcc/jit/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/jit/jit-recording.c | 13 |
2 files changed, 14 insertions, 5 deletions
diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index 639f8e6..8f3f412 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,5 +1,11 @@ 2014-12-19 David Malcolm <dmalcolm@redhat.com> + * jit-recording.c (gcc::jit::recording::context::context): When + copying string options from a parent context, take a copy of the + underlying buffers, rather than simply copying the pointer. + +2014-12-19 David Malcolm <dmalcolm@redhat.com> + * jit-recording.c (gcc::jit::recording::context::set_str_option): Handle NULL. diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c index 7d9da24..6613ed7 100644 --- a/gcc/jit/jit-recording.c +++ b/gcc/jit/jit-recording.c @@ -181,11 +181,14 @@ recording::context::context (context *parent_ctxt) { if (parent_ctxt) { - /* Inherit options from parent. - Note that the first memcpy means copying pointers to strings. */ - memcpy (m_str_options, - parent_ctxt->m_str_options, - sizeof (m_str_options)); + /* Inherit options from parent. */ + for (unsigned i = 0; + i < sizeof (m_str_options) / sizeof (m_str_options[0]); + i++) + { + const char *parent_opt = parent_ctxt->m_str_options[i]; + m_str_options[i] = parent_opt ? xstrdup (parent_opt) : NULL; + } memcpy (m_int_options, parent_ctxt->m_int_options, sizeof (m_int_options)); |