From 10f5d74737db62dc6acdb1bb740e499ebb6b34c2 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 9 May 2013 22:33:08 +0200 Subject: [PATCH] Fix uninitialized vars in EnumDeclaration 'protection' and 'parent' are used in ScopeDSymbol::search detected by Valgrind). The assignment in semantic0 is enough to fix the bug, but I also added an initialization to the constructor. This is a backport of DMD commit 4dfaf02d4d by Don Clugston. --- dmd2/enum.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dmd2/enum.c b/dmd2/enum.c index df01847e..1addb844 100644 --- a/dmd2/enum.c +++ b/dmd2/enum.c @@ -38,6 +38,8 @@ EnumDeclaration::EnumDeclaration(Loc loc, Identifier *id, Type *memtype) #if IN_DMD objFileDone = 0; #endif + protection = PROTundefined; + parent = NULL; } Dsymbol *EnumDeclaration::syntaxCopy(Dsymbol *s) @@ -79,6 +81,10 @@ void EnumDeclaration::semantic0(Scope *sc) if (isdone || !scope) return; + + parent = scope->parent; + protection = scope->protection; + if (!isAnonymous() || memtype) return; for (size_t i = 0; i < members->dim; i++)