summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhinder <hinder@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-11-20 13:48:01 +0000
committerhinder <hinder@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-11-20 13:48:01 +0000
commitc162c0cdf7a92017a41ca48fcc9f25fb4eef6674 (patch)
tree38d6fbf57eb84f7bd2c2a20d2e61846d02b0c9b8 /src
parent37acc03c7c5cbf8901dc0af9cbe16acbe4e96237 (diff)
ParseFile.c: Change semantics of call to fread so that error check makes sense
fread takes an "item size" and a "number of items" and returns the number of items successfully read. Previously, we asked for 1 item of the size of the file, to read the entire file. The error check which was added in r4915 assumed that the returned value of fread was the number of bytes read, which is not correct since only one item is returned, and causes Cactus to fail with a fatal error when any parameter file is loaded. The present commit changes the fread call to ask for file_size items of size 1, for which the error-checking code makes sense, as there are now file_size items returned. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4917 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src')
-rw-r--r--src/util/ParseFile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/util/ParseFile.c b/src/util/ParseFile.c
index 751bed98..17a5253e 100644
--- a/src/util/ParseFile.c
+++ b/src/util/ParseFile.c
@@ -335,7 +335,7 @@ static char *ReadFile(FILE *file, unsigned long *filesize)
return NULL;
}
/* Read file into buffer and return */
- bytes_read = fread(buffer, *filesize, 1, file);
+ bytes_read = fread(buffer, 1, *filesize, file);
if (bytes_read != *filesize)
{
fprintf(stderr, "File size changed while reading.\n");