summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-10-31 21:52:43 +0200
committerArnold D. Robbins <arnold@skeeve.com>2016-11-07 20:55:04 +0200
commite886bf34a4e42095824a2b14c40cb19efa80390f (patch)
tree01099a9c2304d15f26adeaac144a7ded4f663655
parent3fa6f02daabc1bf2cc21f7854c4af990627a8863 (diff)
downloadgawk-e886bf34a4e42095824a2b14c40cb19efa80390f.tar.gz
Fix some valgrind errors.
-rw-r--r--ChangeLog6
-rw-r--r--io.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ecd371ba..7d3b0f0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,12 @@
* nonposix.h (w32_maybe_set_errno) [__MINGW32__]: Add prototype.
+2016-10-31 Arnold D. Robbins <arnold@skeeve.com>
+
+ Fix valgrind issues.
+
+ * io.c (init_awkpath): Need to allocate max_path+3 pointers.
+
2016-10-26 Arnold D. Robbins <arnold@skeeve.com>
* io.c (init_awkpath): Set max path len for leading separator.
diff --git a/io.c b/io.c
index ab4029e1..2dbc07a6 100644
--- a/io.c
+++ b/io.c
@@ -2607,8 +2607,9 @@ init_awkpath(path_info *pi)
if (*p == envsep)
max_path++;
- emalloc(pi->awkpath, char **, (max_path + 1) * sizeof(char *), "init_awkpath");
- memset(pi->awkpath, 0, (max_path + 1) * sizeof(char *));
+ // +3 --> 2 for null entries at front and end of path, 1 for NULL end of list
+ emalloc(pi->awkpath, char **, (max_path + 3) * sizeof(char *), "init_awkpath");
+ memset(pi->awkpath, 0, (max_path + 3) * sizeof(char *));
start = path;
i = 0;