summaryrefslogtreecommitdiffstats
path: root/clang/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2009-12-17 09:18:43 +0000
committerChandler Carruth <chandlerc@gmail.com>2009-12-17 09:18:43 +0000
commit65ce1b7c612988fd15cae6589a05317de513bff1 (patch)
treef4762dbcea8f2fe2d699d3200b935b61083259f0 /clang/tools/c-index-test/c-index-test.c
parent108b0682e4bba7fda67e27c5d6956a034ad6b605 (diff)
downloadbcm5719-llvm-65ce1b7c612988fd15cae6589a05317de513bff1.tar.gz
bcm5719-llvm-65ce1b7c612988fd15cae6589a05317de513bff1.zip
Test for errors during fread() inside c-index-test and handle them
appropriately. This also silences some pedantic GCC warnings. llvm-svn: 91596
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r--clang/tools/c-index-test/c-index-test.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index 7300585a1d8..7040a7288a1 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -461,7 +461,15 @@ int parse_remapped_files(int argc, const char **argv, int start_arg,
/* Read the contents of the file we're remapping to. */
contents = (char *)malloc(unsaved->Length + 1);
- fread(contents, 1, unsaved->Length, to_file);
+ if (fread(contents, 1, unsaved->Length, to_file) != unsaved->Length) {
+ fprintf(stderr, "error: unexpected %s reading 'to' file %s\n",
+ (feof(to_file) ? "EOF" : "error"), semi + 1);
+ fclose(to_file);
+ free_remapped_files(*unsaved_files, i);
+ *unsaved_files = 0;
+ *num_unsaved_files = 0;
+ return -1;
+ }
contents[unsaved->Length] = 0;
unsaved->Contents = contents;
OpenPOWER on IntegriCloud