harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 0226e3a5f69e1b2dc4c8e5cab61eb3feb9f7f41f
parent 601c16ba9784ba25d8a8ad568a0fcb3d7e9e1a50
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date:   Sat, 19 Feb 2022 04:15:07 +0100

fix a null dereference and a memory leak

Variable obj may be null in some circumstances. This also prevents
identifier_unparse from running every time a declaration is scanned.

Signed-off-by: Bor Grošelj Simić <bor.groseljsimic@telemach.net>

Diffstat:
Msrc/check.c | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -3570,9 +3570,11 @@ scan_decl_finish(struct context *ctx, const struct scope_object *obj, } // resolving a declaration that is already in progress -> cycle - expect(&idecl->decl.loc, !idecl->in_progress, - "Circular dependency for '%s'\n", - identifier_unparse(&obj->ident)); + if (idecl->in_progress) { + expect(&idecl->decl.loc, false, + "Circular dependency for '%s'\n", + identifier_unparse(&idecl->obj.ident)); + } idecl->in_progress = true; switch (idecl->decl.decl_type) {