Permalink
Browse files

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.
  • Loading branch information...
don-clugston-sociomantic committed Mar 22, 2013
1 parent 0442749 commit 4dfaf02d4d145ae89a0069671ffd7020e2eb4131
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/enum.c
View
@@ -34,6 +34,8 @@ EnumDeclaration::EnumDeclaration(Loc loc, Identifier *id, Type *memtype)
isdeprecated = 0;
isdone = 0;
objFileDone = 0;
+ protection = PROTundefined;
+ parent = NULL;
}
Dsymbol *EnumDeclaration::syntaxCopy(Dsymbol *s)
@@ -75,6 +77,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++)

0 comments on commit 4dfaf02

Please sign in to comment.