]> granicus.if.org Git - clang/commitdiff
Attempt to fix a read-after-free running test/Sema/designated-initializers.c.
authorEli Friedman <eli.friedman@gmail.com>
Thu, 16 Apr 2009 17:49:48 +0000 (17:49 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 16 Apr 2009 17:49:48 +0000 (17:49 +0000)
Douglas, can you check that this is doing the right thing?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69298 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaInit.cpp

index a0f4e4ac385f19c562fdd69932b65a8ae2ac6196..28b25565b14bf8f647f2e9bd227b17b9645be0aa 100644 (file)
@@ -1234,15 +1234,15 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
         ExpandAnonymousFieldDesignator(SemaRef, DIE, DesigIdx, 
                                        cast<FieldDecl>(*Lookup.first),
                                        Field, FieldIndex);
+        D = DIE->getDesignator(DesigIdx);
       } else {
         // Name lookup found something, but it wasn't a field.
         SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_nonfield)
           << FieldName;
         SemaRef.Diag((*Lookup.first)->getLocation(), 
                       diag::note_field_designator_found);
-
-      ++Index;
-      return true;
+        ++Index;
+        return true;
       }
     } else if (!KnownField &&
                cast<RecordDecl>((*Field)->getDeclContext())