]> granicus.if.org Git - clang/commitdiff
[c-index-test] Fix leak in print_completion_result, NFC
authorVedant Kumar <vsk@apple.com>
Sun, 3 Apr 2016 00:54:46 +0000 (00:54 +0000)
committerVedant Kumar <vsk@apple.com>
Sun, 3 Apr 2016 00:54:46 +0000 (00:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265252 91177308-0d34-0410-b5e6-96231b3b80d8

tools/c-index-test/c-index-test.c

index c76d8fb0e7d180604ff95e67621c9a617304988a..b3105fb87c1271156369bb3ce1effcccdef3d1e1 100644 (file)
@@ -1997,6 +1997,7 @@ static void print_completion_result(CXCompletionResult *completion_result,
   enum CXCursorKind ParentKind;
   CXString ParentName;
   CXString BriefComment;
+  CXString Annotation;
   const char *BriefCommentCString;
   
   fprintf(file, "%s:", clang_getCString(ks));
@@ -2030,9 +2031,10 @@ static void print_completion_result(CXCompletionResult *completion_result,
     for (i = 0; i < annotationCount; ++i) {
       if (i != 0)
         fprintf(file, ", ");
-      fprintf(file, "\"%s\"",
-              clang_getCString(clang_getCompletionAnnotation(
-                                 completion_result->CompletionString, i)));
+      Annotation =
+          clang_getCompletionAnnotation(completion_result->CompletionString, i);
+      fprintf(file, "\"%s\"", clang_getCString(Annotation));
+      clang_disposeString(Annotation);
     }
     fprintf(file, ")");
   }