public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ubsan: expr.c:1725,1741 signed integer overflow
@ 2020-09-02  8:42 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2020-09-02  8:42 UTC (permalink / raw)
  To: binutils

	* expr.c (add_to_result, subtract_from_result): Use unsigned
	addition and subtraction.

diff --git a/gas/expr.c b/gas/expr.c
index da4fbcf8cd..6f74de786d 100644
--- a/gas/expr.c
+++ b/gas/expr.c
@@ -1722,7 +1722,7 @@ add_to_result (expressionS *resultP, offsetT amount, int rhs_highbit)
   valueT ures = resultP->X_add_number;
   valueT uamount = amount;
 
-  resultP->X_add_number += amount;
+  resultP->X_add_number += uamount;
 
   resultP->X_extrabit ^= rhs_highbit;
 
@@ -1738,7 +1738,7 @@ subtract_from_result (expressionS *resultP, offsetT amount, int rhs_highbit)
   valueT ures = resultP->X_add_number;
   valueT uamount = amount;
 
-  resultP->X_add_number -= amount;
+  resultP->X_add_number -= uamount;
 
   resultP->X_extrabit ^= rhs_highbit;
 
-- 
Alan Modra
Australia Development Lab, IBM


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-02  8:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-02  8:42 ubsan: expr.c:1725,1741 signed integer overflow Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).