[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/9] scan_profile(): Make sure the buffers are initialized
From: |
Tim Hentenaar |
Subject: |
[PATCH 4/9] scan_profile(): Make sure the buffers are initialized |
Date: |
Wed, 17 Jun 2015 20:56:00 +0200 |
Be sure to initialize the two char buffers in scan_profile().
This fixes a warning from valgrind about the conditional at
of BUFSIZ chars with automatic storage duration. This fixes a warning
from valgrind about the conditional on line 805 relying on uninitialized
data.
---
ChangeLog | 2 ++
src/args.c | 5 +++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d281eba..18251a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,8 @@
* Add xfree() to globs.
* xfree() common heap-allocated storage.
* Fixed some memory leaks in the profile stuff.
+ * Be sure to initialize the two automatic storage buffers used in
+ scan_profile(). This fixes a warnings from valgrind.
2015-06-15 Tim Hentenaar <address@hidden>
* Added -par to -kr.
diff --git a/src/args.c b/src/args.c
index 1d2bd75..1951749 100644
--- a/src/args.c
+++ b/src/args.c
@@ -1109,7 +1109,6 @@ static int read_string(
/**
* Scan the options in the file f.
*/
-
static void scan_profile(
FILE * f,
const char * option_source)
@@ -1117,8 +1116,10 @@ static void scan_profile(
char b0[BUFSIZ];
char b1[BUFSIZ];
char * current = b0;
-
int i = skip_spaces(f, ' ');
+
+ memset(b0, 0, BUFSIZ);
+ memset(b1, 0, BUFSIZ);
while (i != EOF)
{
--
2.3.6
- [PATCH 0/9] More bugfixes, etc., Tim Hentenaar, 2015/06/17
- [PATCH 1/9] Add regressions mising from upstream, Tim Hentenaar, 2015/06/17
- [PATCH 4/9] scan_profile(): Make sure the buffers are initialized,
Tim Hentenaar <=
- [PATCH 2/9] comments.c: Fix print_comment reading past the end of the buffer when reading less than a full comment from stdin., Tim Hentenaar, 2015/06/17
- [PATCH 8/9] -npcs: Fix recognition of function pointers, Tim Hentenaar, 2015/06/17
- [PATCH 6/9] indent.c: Don't force nl between rbrace and comma, Tim Hentenaar, 2015/06/17
- [PATCH 9/9] Add an install target to the regression Makefile, Tim Hentenaar, 2015/06/17
- [PATCH 3/9] Fix several potential memory leaks, Tim Hentenaar, 2015/06/17
- [PATCH 7/9] Don't tab-align comments (-ntac), Tim Hentenaar, 2015/06/17
- [PATCH 5/9] comments.c: Fix heap corruption, Tim Hentenaar, 2015/06/17