summary refs log tree commit diff
path: root/argp
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-01-07 02:06:16 +0100
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-02-04 16:44:20 -0300
commit5ec029c8835b71d7a3d6036c9358198b4d9e59fc (patch)
tree5e99ce85d7d23520c1047bfb4510b4d465607f29 /argp
parentdfc3907cde01f1f15d962f3c9eda9fad1fc7b74f (diff)
downloadglibc-5ec029c8835b71d7a3d6036c9358198b4d9e59fc.tar.gz
glibc-5ec029c8835b71d7a3d6036c9358198b4d9e59fc.tar.xz
glibc-5ec029c8835b71d7a3d6036c9358198b4d9e59fc.zip
argp: fix pointer-subtraction bug
* argp/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

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'argp')
-rw-r--r--argp/argp-help.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 15c5fd237b..f417e1294c 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -867,7 +867,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.  */