From: Michal MalĂ˝ Date: Thu, 18 Aug 2016 15:08:13 +0000 (+0200) Subject: Fix return value check from fread X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=6ed0fb4b2f3be5cfc933d5fb6482e877a39e5dbe;p=libHPCS.git Fix return value check from fread --- 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; }