diff mbox series

[1/5] argp: fix pointer-subtraction bug

Message ID 1745404.52eaX7kXFs@omega
State New
Headers show
Series [1/5] argp: fix pointer-subtraction bug | expand

Commit Message

Bruno Haible Jan. 7, 2021, 1:14 a.m. UTC
This patch is attached. (git send-email did not send it because it is
authored by Paul, not me.)
diff mbox series

Patch

From 5a404daee6857506202b5a5eed331aba760b2308 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 7 Jan 2021 00:51:33 +0100
Subject: [PATCH 1/5] argp: fix pointer-subtraction bug
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* 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
---
 argp/argp-help.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/argp/argp-help.c b/argp/argp-help.c
index 15c5fd2..f417e12 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.  */
-- 
2.7.4