tisc

tiny instruction set computer
Log | Files | Refs | README

commit ad8d41ca2d19dc4de4d487f6a0b8b527cf96a4e0
parent 103f0c3884b8ac2fab638d3ac31ef13a23c701a6
Author: Paul Longtine <paul@nanner.co>
Date:   Sun, 19 Jun 2022 21:46:18 -0400

Fix use of uninitialized memory

Diffstat:
Mtisc.c | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/tisc.c b/tisc.c @@ -651,6 +651,11 @@ void print_instruction(int line, int* address, char *label, char *opcode, char * { arg_str = (char*)malloc(sizeof(char) * len); + for (int i = 0; i < len; i++) + { + arg_str[i] = '\0'; + } + for (int i = 0; arg[i] != NULL && i < 3; i++) { sprintf(arg_str, "%s%s\t", arg_str, arg[i]);