From 706e4e97587b04d0bcdd360a8042eefca879997f Mon Sep 17 00:00:00 2001 From: Olaf Seibert Date: Sat, 23 Jan 2021 22:06:12 +0100 Subject: [PATCH] Clang found an uninitialized pointer. --- extree.c | 2 +- parse.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/extree.c b/extree.c index 57444a6..3b5808d 100644 --- a/extree.c +++ b/extree.c @@ -718,7 +718,7 @@ EX_TREE *evaluate( EX_TREE *new_ex_tree( void) { - EX_TREE *tr = memcheck(malloc(sizeof(EX_TREE))); + EX_TREE *tr = memcheck(calloc(1, sizeof(EX_TREE))); return tr; } diff --git a/parse.c b/parse.c index 7e158b9..8ceab19 100644 --- a/parse.c +++ b/parse.c @@ -951,7 +951,7 @@ EX_TREE *parse_unary( char bound = tolower((unsigned char)cp[2]); char *cp2 = skipwhite(cp + 3); int islocal = 0; - char *endcp; + char *endcp = NULL; char *psectname = get_symbol(cp2, &endcp, &islocal); SYMBOL *sectsym = psectname ? lookup_sym(psectname, §ion_st) : NULL; @@ -974,6 +974,9 @@ EX_TREE *parse_unary( } } else { /* report(stack->top, "psect name %s not found\n", psectname); */ + if (!endcp) { + endcp = cp; + } if (pass == 0) { /* * During the first pass it is expected that the psect is not