From 6ed0fb4b2f3be5cfc933d5fb6482e877a39e5dbe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Thu, 18 Aug 2016 17:08:13 +0200 Subject: [PATCH] Fix return value check from fread --- libhpcs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libhpcs.c b/libhpcs.c index 827ac5d..c660971 100644 --- a/libhpcs.c +++ b/libhpcs.c @@ -905,14 +905,14 @@ static enum HPCS_ParseCode read_generic_type(FILE* datafile, enum HPCS_GenType* if (ferror(datafile)) return PARSE_E_CANT_READ; - if (fread(&len, SMALL_SEGMENT_SIZE, 1, datafile) < SMALL_SEGMENT_SIZE) + if (fread(&len, SMALL_SEGMENT_SIZE, 1, datafile) < 1) return PARSE_E_CANT_READ; gentype_str = malloc((sizeof(char) * len) + 1); if (gentype_str == NULL) return PARSE_E_NO_MEM; - if (fread(gentype_str, SMALL_SEGMENT_SIZE, len, datafile) < SMALL_SEGMENT_SIZE * len) { + if (fread(gentype_str, SMALL_SEGMENT_SIZE, len, datafile) < len) { ret = PARSE_E_CANT_READ; goto out; } -- 2.43.5