bug-indent
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]