[Midnightbsd-cvs] src [8791] trunk/contrib/nvi: Fix two instances of undefined behavior in contrib/nvi

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Sep 25 23:18:38 EDT 2016


Revision: 8791
          http://svnweb.midnightbsd.org/src/?rev=8791
Author:   laffer1
Date:     2016-09-25 23:18:38 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
Fix two instances of undefined behavior in contrib/nvi

Modified Paths:
--------------
    trunk/contrib/nvi/ex/ex_txt.c
    trunk/contrib/nvi/vi/v_txt.c

Modified: trunk/contrib/nvi/ex/ex_txt.c
===================================================================
--- trunk/contrib/nvi/ex/ex_txt.c	2016-09-26 03:18:06 UTC (rev 8790)
+++ trunk/contrib/nvi/ex/ex_txt.c	2016-09-26 03:18:38 UTC (rev 8791)
@@ -398,8 +398,8 @@
 			++scno;
 
 	/* Get the previous shiftwidth column. */
-	cno = scno;
-	scno -= --scno % sw;
+	cno = scno--;
+	scno -= scno % sw;
 
 	/*
 	 * Since we don't know what comes before the character(s) being

Modified: trunk/contrib/nvi/vi/v_txt.c
===================================================================
--- trunk/contrib/nvi/vi/v_txt.c	2016-09-26 03:18:06 UTC (rev 8790)
+++ trunk/contrib/nvi/vi/v_txt.c	2016-09-26 03:18:38 UTC (rev 8791)
@@ -1956,8 +1956,10 @@
 	target = current;
 	if (isindent)
 		target += COL_OFF(target, sw);
-	else
-		target -= --target % sw;
+	else {
+		--target;
+		target -= target % sw;
+	}
 
 	/*
 	 * The AI characters will be turned into overwrite characters if the



More information about the Midnightbsd-cvs mailing list