diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-07-05 08:20:49 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-07-05 08:20:49 +0000 |
commit | 1ea42eb5a33bb48c5ce085e27c2701a6e8563645 (patch) | |
tree | a14383760616ef65e62b27cb343d07cde9acabb2 /clang/tools/c-index-test/c-index-test.c | |
parent | 78a3bbc82c2dbfc900964b2f98d0a51fc2b52b01 (diff) | |
download | bcm5719-llvm-1ea42eb5a33bb48c5ce085e27c2701a6e8563645.tar.gz bcm5719-llvm-1ea42eb5a33bb48c5ce085e27c2701a6e8563645.zip |
Fix some memory leaks found by the static analyzer. Thanks to John Smith for running it over Clang.
llvm-svn: 159732
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r-- | clang/tools/c-index-test/c-index-test.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index e16be7d185f..b3b5b8447ff 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -157,6 +157,7 @@ int parse_remapped_files(int argc, const char **argv, int start_arg, (feof(to_file) ? "EOF" : "error"), semi + 1); fclose(to_file); free_remapped_files(*unsaved_files, i); + free(contents); *unsaved_files = 0; *num_unsaved_files = 0; return -1; @@ -2281,8 +2282,10 @@ int perform_token_annotation(int argc, const char **argv) { &second_line, &second_column))) return errorCode; - if (parse_remapped_files(argc, argv, 2, &unsaved_files, &num_unsaved_files)) + if (parse_remapped_files(argc, argv, 2, &unsaved_files, &num_unsaved_files)) { + free(filename); return -1; + } CIdx = clang_createIndex(0, 1); TU = clang_parseTranslationUnit(CIdx, argv[argc - 1], @@ -2300,8 +2303,10 @@ int perform_token_annotation(int argc, const char **argv) { } errorCode = 0; - if (checkForErrors(TU) != 0) - return -1; + if (checkForErrors(TU) != 0) { + errorCode = -1; + goto teardown; + } if (getenv("CINDEXTEST_EDITING")) { for (i = 0; i < 5; ++i) { |