svn commit: r246981 - in stable: 7/contrib/nvi/ex 7/contrib/nvi/vi 8/contrib/nvi/ex 8/contrib/nvi/vi 9/contrib/nvi/ex 9/contrib/nvi/vi

Dimitry Andric dim at FreeBSD.org
Tue Feb 19 07:55:55 UTC 2013


Author: dim
Date: Tue Feb 19 07:55:53 2013
New Revision: 246981
URL: http://svnweb.freebsd.org/changeset/base/246981

Log:
  MFC r246874:
  
  Fix two instances of undefined behaviour in contrib/nvi.
  
  Found by:	clang ToT
  Obtained from:	NetBSD
  Reviewed by:	jh

Modified:
  stable/7/contrib/nvi/ex/ex_txt.c
  stable/7/contrib/nvi/vi/v_txt.c
Directory Properties:
  stable/7/contrib/nvi/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/8/contrib/nvi/ex/ex_txt.c
  stable/8/contrib/nvi/vi/v_txt.c
  stable/9/contrib/nvi/ex/ex_txt.c
  stable/9/contrib/nvi/vi/v_txt.c
Directory Properties:
  stable/8/contrib/nvi/   (props changed)
  stable/9/contrib/nvi/   (props changed)

Modified: stable/7/contrib/nvi/ex/ex_txt.c
==============================================================================
--- stable/7/contrib/nvi/ex/ex_txt.c	Tue Feb 19 07:50:10 2013	(r246980)
+++ stable/7/contrib/nvi/ex/ex_txt.c	Tue Feb 19 07:55:53 2013	(r246981)
@@ -398,8 +398,8 @@ txt_dent(sp, tp)
 			++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: stable/7/contrib/nvi/vi/v_txt.c
==============================================================================
--- stable/7/contrib/nvi/vi/v_txt.c	Tue Feb 19 07:50:10 2013	(r246980)
+++ stable/7/contrib/nvi/vi/v_txt.c	Tue Feb 19 07:55:53 2013	(r246981)
@@ -1956,8 +1956,10 @@ txt_dent(sp, tp, isindent)
 	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 svn-src-all mailing list