[Darwin] Fix two off-by-one errors in the driver.
authorIain Sandoe <iain@sandoe.co.uk>
Wed, 19 Jun 2019 16:07:58 +0000 (16:07 +0000)
committerIain Sandoe <iains@gcc.gnu.org>
Wed, 19 Jun 2019 16:07:58 +0000 (16:07 +0000)
2019-06-19  Iain Sandoe  <iain@sandoe.co.uk>

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

From-SVN: r272479

gcc/ChangeLog
gcc/config/darwin-driver.c

index e5c455f3b8d548f190867283f04f3239369b3dab..919ceafd3a31a7899702a458664b2fdbc62c79ed 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-19  Iain Sandoe  <iain@sandoe.co.uk>
+
+        * config/darwin-driver.c (darwin_driver_init): Fix off-by-one errors
+        in computing the number of options to be moved.
+
 2019-06-19  Maya Rashish  <coypu@sdf.org>
 
        *  config/arm/netbsd-elf.h (SYSARCH_ARM_SYNC_ICACHE): New definition.
index 01238e2634da4f4e9c44641ddd8f3df36553bc7d..3d85f29cb3d89b673c33018d91145c11a2dc6dd3 100644 (file)
@@ -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;