Fix --enable-offload-targets/-foffload handling, pt. 2
authorThomas Schwinge <thomas@codesourcery.com>
Wed, 23 Sep 2015 14:52:57 +0000 (16:52 +0200)
committerThomas Schwinge <tschwinge@gcc.gnu.org>
Wed, 23 Sep 2015 14:52:57 +0000 (16:52 +0200)
gcc/
* gcc.c (handle_foffload_option): Don't lose the trailing NUL
character when appending to offload_targets.

From-SVN: r228054

gcc/ChangeLog
gcc/gcc.c

index df71558a7e532f3b63a707ad4d49b95eefd37902..ca89477050481020dafc6c83f0609cdb56097ddb 100644 (file)
@@ -1,5 +1,8 @@
 2015-09-23  Thomas Schwinge  <thomas@codesourcery.com>
 
+       * gcc.c (handle_foffload_option): Don't lose the trailing NUL
+       character when appending to offload_targets.
+
        * configure.ac (offload_targets, OFFLOAD_TARGETS): Separate
        offload targets by commas, not colons.
        * config.in: Regenerate.
index 78b68e28aa655fffcdd56be186dfd96d1e3df499..ef132d6fecef34cd31b4c9ab0d4e7f9c749e7776 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -3657,10 +3657,9 @@ handle_foffload_option (const char *arg)
              size_t offload_targets_len = strlen (offload_targets);
              offload_targets
                = XRESIZEVEC (char, offload_targets,
-                             offload_targets_len + next - cur + 2);
-             if (offload_targets_len)
-               offload_targets[offload_targets_len++] = ':';
-             memcpy (offload_targets + offload_targets_len, target, next - cur);
+                             offload_targets_len + 1 + next - cur + 1);
+             offload_targets[offload_targets_len++] = ':';
+             memcpy (offload_targets + offload_targets_len, target, next - cur + 1);
            }
        }