[cfe-commits] r159732 - /cfe/trunk/tools/c-index-test/c-index-test.c
Richard Smith
richard-llvm at metafoo.co.uk
Thu Jul 5 01:20:49 PDT 2012
Author: rsmith
Date: Thu Jul 5 03:20:49 2012
New Revision: 159732
URL: http://llvm.org/viewvc/llvm-project?rev=159732&view=rev
Log:
Fix some memory leaks found by the static analyzer. Thanks to John Smith for running it over Clang.
Modified:
cfe/trunk/tools/c-index-test/c-index-test.c
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=159732&r1=159731&r2=159732&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Jul 5 03:20:49 2012
@@ -157,6 +157,7 @@
(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 @@
&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 @@
}
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) {
More information about the cfe-commits
mailing list