summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMark Lumsden <lum@cvs.openbsd.org>2016-09-05 08:10:59 +0000
committerMark Lumsden <lum@cvs.openbsd.org>2016-09-05 08:10:59 +0000
commit2049b37526cd15293aec02cbe7978a46aa91a484 (patch)
treeabe5de38c2ecdc5a6e4d27d3cbaa3079039942c2 /usr.bin
parentc804c610bd3bc9cc8e3a99f45819015cba9829d5 (diff)
Initialize stack variables to zero before memmove().
Coverity Scan reported these two stack variables as uninitialized, in particular the .r_lineno struct member was uninitialized. This patch clears the 'struct region' rather than setting .r_lineno because if any more struct members are added in the future the clear will cover them too. Source Joachim Nilsson. ok tom@ millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/undo.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/usr.bin/mg/undo.c b/usr.bin/mg/undo.c
index 62b29fd9c46..6e87d9cc632 100644
--- a/usr.bin/mg/undo.c
+++ b/usr.bin/mg/undo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: undo.c,v 1.57 2015/12/11 20:21:23 mmcc Exp $ */
+/* $OpenBSD: undo.c,v 1.58 2016/09/05 08:10:58 lum Exp $ */
/*
* This file is in the public domain
*/
@@ -269,6 +269,8 @@ undo_add_insert(struct line *lp, int offset, int size)
if (!undo_enable_flag)
return (TRUE);
+
+ memset(&reg, 0, sizeof(reg));
reg.r_linep = lp;
reg.r_offset = offset;
reg.r_size = size;
@@ -315,6 +317,7 @@ undo_add_delete(struct line *lp, int offset, int size, int isreg)
if (!undo_enable_flag)
return (TRUE);
+ memset(&reg, 0, sizeof(reg));
reg.r_linep = lp;
reg.r_offset = offset;
reg.r_size = size;