aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2023-11-24 10:49:41 +0200
committerArnold D. Robbins <arnold@skeeve.com>2023-11-24 10:49:41 +0200
commit1c424b1b4d5931f2a4b87b6f0f75827bc53ff9d7 (patch)
tree122aa55321dbde5f3ceb5ea5878a7c12ece49785
parent35d462741379ef4616d67ade48058a5e3490f77e (diff)
downloadone-true-awk-1c424b1b4d5931f2a4b87b6f0f75827bc53ff9d7.tar.gz
Initialize realloced memory to zero.
-rw-r--r--b.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/b.c b/b.c
index 4bc43bf..881c052 100644
--- a/b.c
+++ b/b.c
@@ -602,7 +602,12 @@ static void resize_gototab(fa *f, int state)
gtte *p = (gtte *) realloc(f->gototab[state].entries, new_size * sizeof(gtte));
if (p == NULL)
overflo(__func__);
- f->gototab[state].allocated = new_size;
+
+ // need to initialized the new memory to zero
+ size_t orig_size = f->gototab[state].allocated; // 2nd half of new mem is this size
+ memset(p + orig_size, 0, orig_size * sizeof(gtte)); // clean it out
+
+ f->gototab[state].allocated = new_size; // update gotottab info
f->gototab[state].entries = p;
}