From 93f61120ddba2093d85dbd09dff2deb42f0393e2 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 13 Apr 2025 20:44:02 +0300 Subject: properly initialize all allocated structures * Fixes access to uninitialized field in cmd_token, as found via Valgrind. * Possibly other structures also aren't fully initialized, so I memset() them as well. --- tecparse.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'tecparse.c') diff --git a/tecparse.c b/tecparse.c index 90d4b5f..e726ea6 100644 --- a/tecparse.c +++ b/tecparse.c @@ -1303,21 +1303,8 @@ register struct cmd_token *ct; * We set up the initial state to be that of an empty token, with fields * which are not set up yet set to their proper defaults. */ - ct->opcode = TOK_C_UNUSED; - ct->ctx.iarg1_flag = ct->ctx.iarg2_flag = NO; - ct->ctx.iarg1 = ct->ctx.iarg2 = 0; - ct->ctx.carg = NULL; - ct->next_token = NULL; - ct->undo_list = NULL; - ct->execute_state = 0; - ct->flags = 0; + memset(ct,0,sizeof(*ct)); - ct->prev_token = NULL; - ct->ctx.state = 0; - ct->ctx.go_flag = NO; - ct->ctx.return_state = 0; - ct->ctx.caller_token = NULL; - ct->ctx.pnest = ct->ctx.inest = ct->ctx.cnest = 0; /* * If there was an old token specified, two things must happen. First, we * have to link the new token onto the old token list. Second, we have to -- cgit v1.2.3