From 176b63b62ec8e9ee1cc782d25399f3abf25c85f2 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 28 Mar 2011 18:47:13 +0200 Subject: Fix up stream error handling --- src/partialator.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/partialator.c') diff --git a/src/partialator.c b/src/partialator.c index 0e2cfb2e..ea3eb50c 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -262,6 +262,10 @@ int main(int argc, char *argv[]) } n_total_patterns = count_patterns(fh); + if ( n_total_patterns == 0 ) { + ERROR("No patterns to process.\n"); + return 1; + } STATUS("There are %i patterns to process\n", n_total_patterns); images = malloc(n_total_patterns * sizeof(struct image)); @@ -280,7 +284,9 @@ int main(int argc, char *argv[]) Reflection *refl; RefListIterator *iter; - if ( read_chunk(fh, &images[i]) == 1 ) { + if ( read_chunk(fh, &images[i]) != 0 ) { + /* Should not happen, because we counted the patterns + * earlier. */ ERROR("Failed to read chunk from the input stream.\n"); return 1; } -- cgit v1.2.3