From: Paul Eggert Date: Thu, 7 Jan 2021 01:06:16 +0000 (+0100) Subject: argp: fix pointer-subtraction bug X-Git-Tag: glibc-2.34~982 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5ec029c8835b71d7a3d6036c9358198b4d9e59fc;p=thirdparty%2Fglibc.git 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 --- diff --git a/argp/argp-help.c b/argp/argp-help.c index 15c5fd237b1..f417e1294c0 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. */