Skip to content

Commit

Permalink
Fix uninitialized vars in EnumDeclaration
Browse files Browse the repository at this point in the history
'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 4dfaf02
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/enum.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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++)
Expand Down

0 comments on commit 4dfaf02

Please sign in to comment.