summaryrefslogtreecommitdiffstats
path: root/clang/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2014-04-24 04:14:12 +0000
committerNico Weber <nicolasweber@gmx.de>2014-04-24 04:14:12 +0000
commit82098cb6dfc80dad8167c6dfbc036eb402ce52ff (patch)
tree30e9b0d78167d1516801decf4498436d623ecc5d /clang/tools/c-index-test/c-index-test.c
parent2803df5ae6085aa968966f85f26ff0c4817e91ad (diff)
downloadbcm5719-llvm-82098cb6dfc80dad8167c6dfbc036eb402ce52ff.tar.gz
bcm5719-llvm-82098cb6dfc80dad8167c6dfbc036eb402ce52ff.zip
Fix two leaks in c-index-test found by LSan.
The result of clang_getCursorSpelling() needs to be clang_getCursorSpelling()ed. llvm-svn: 207073
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r--clang/tools/c-index-test/c-index-test.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index 461765c13a8..aec5f1bd64f 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -1333,18 +1333,25 @@ static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
}
/* Print the record field offset if applicable. */
{
- const char *FieldName = clang_getCString(clang_getCursorSpelling(cursor));
+ CXString FieldSpelling = clang_getCursorSpelling(cursor);
+ const char *FieldName = clang_getCString(FieldSpelling);
/* recurse to get the root anonymous record parent */
CXCursor Parent, Root;
- if (clang_getCursorKind(cursor) == CXCursor_FieldDecl ) {
- const char *RootParentName;
+ if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) {
+ CXString RootParentSpelling;
+ const char *RootParentName = 0;
Parent = p;
do {
+ if (RootParentName != 0)
+ clang_disposeString(RootParentSpelling);
+
Root = Parent;
- RootParentName = clang_getCString(clang_getCursorSpelling(Root));
+ RootParentSpelling = clang_getCursorSpelling(Root);
+ RootParentName = clang_getCString(RootParentSpelling);
Parent = clang_getCursorSemanticParent(Root);
- } while ( clang_getCursorType(Parent).kind == CXType_Record &&
- !strcmp(RootParentName, "") );
+ } while (clang_getCursorType(Parent).kind == CXType_Record &&
+ !strcmp(RootParentName, ""));
+ clang_disposeString(RootParentSpelling);
/* if RootParentName is "", record is anonymous. */
{
long long Offset = clang_Type_getOffsetOf(clang_getCursorType(Root),
@@ -1352,6 +1359,7 @@ static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
printf(" [offsetof=%lld]", Offset);
}
}
+ clang_disposeString(FieldSpelling);
}
/* Print if its a bitfield */
{
OpenPOWER on IntegriCloud