]> Savannah Git Hosting - gnulib.git/commitdiff
argp: fix pointer-subtraction bug
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 May 2017 22:35:24 +0000 (15:35 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 May 2017 22:36:21 +0000 (15:36 -0700)
* lib/argp-help.c (hol_append): Don’t subtract pointers to
different arrays, as this can run afoul of -fcheck-pointer-bounds.
See the thread containing Bruno Haible’s report in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-05/msg00171.html

ChangeLog
lib/argp-help.c

index 889ef119a51c5ea85ba27da7921bde53a45e3b5c..b214252007835815dcf57189972f569497df0c78 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-05-19  Paul Eggert  <eggert@cs.ucla.edu>
+
+       argp: fix pointer-subtraction bug
+       * lib/argp-help.c (hol_append): Don’t subtract pointers to
+       different arrays, as this can run afoul of -fcheck-pointer-bounds.
+       See the thread containing Bruno Haible’s report in:
+       http://lists.gnu.org/archive/html/bug-gnulib/2017-05/msg00171.html
+
 2017-05-19  Bruno Haible  <bruno@clisp.org>
 
        printf-posix tests: Avoid test failure with "gcc --coverage".
index 06329606a72a0e6e553ae36bd37bcfac135922b7..ce9bab96378c188a8aaf087a84f8a3a78dd596e5 100644 (file)
@@ -880,7 +880,8 @@ hol_append (struct hol *hol, struct hol *more)
 
           /* Fix up the short options pointers from HOL.  */
           for (e = entries, left = hol->num_entries; left > 0; e++, left--)
-            e->short_options += (short_options - hol->short_options);
+            e->short_options
+              = short_options + (e->short_options - hol->short_options);
 
           /* Now add the short options from MORE, fixing up its entries
              too.  */