Spotted by Dominique with a sanitised build.

fixed thus on trunk - will backport as needed.
thanks
Iain

2019-06-19  Iain Sandoe  <i...@sandoe.co.uk>

        * config/darwin-driver.c (darwin_driver_init): Fix off-by-one errors
        in computing the number of options to be moved.



diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c
index 01238e2..3d85f29 100644
--- a/gcc/config/darwin-driver.c
+++ b/gcc/config/darwin-driver.c
@@ -261,7 +261,7 @@ darwin_driver_init (unsigned int *decoded_options_count,
          if (*decoded_options_count > i) {
            memmove (*decoded_options + i,
                     *decoded_options + i + 1,
-                    ((*decoded_options_count - i)
+                    ((*decoded_options_count - i - 1)
                      * sizeof (struct cl_decoded_option)));
          }
          --i;
@@ -307,7 +307,7 @@ darwin_driver_init (unsigned int *decoded_options_count,
          if (*decoded_options_count > i) {
            memmove (*decoded_options + i,
                     *decoded_options + i + 1,
-                    ((*decoded_options_count - i)
+                    ((*decoded_options_count - i - 1)
                      * sizeof (struct cl_decoded_option)));
          }
          --i;

Reply via email to