diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2023-11-24 10:49:41 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2023-11-24 10:49:41 +0200 |
commit | 1c424b1b4d5931f2a4b87b6f0f75827bc53ff9d7 (patch) | |
tree | 122aa55321dbde5f3ceb5ea5878a7c12ece49785 | |
parent | 35d462741379ef4616d67ade48058a5e3490f77e (diff) | |
download | one-true-awk-1c424b1b4d5931f2a4b87b6f0f75827bc53ff9d7.tar.gz |
Initialize realloced memory to zero.
-rw-r--r-- | b.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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; } |