diff --git a/example.c b/example.c index 5c4b8ac..9c80821 100644 --- a/example.c +++ b/example.c @@ -241,7 +241,10 @@ static uint8_t *load_file(const char *filename, int *plen) buf_len = ftell(f); fseek(f, 0, SEEK_SET); buf = malloc(buf_len + 1); - fread(buf, 1, buf_len, f); + if (fread(buf, 1, buf_len, f) != buf_len) { + printf("not read %d bytes\n", buf_len); + exit(1); + } buf[buf_len] = '\0'; fclose(f); if (plen) diff --git a/mqjs.c b/mqjs.c index 75a8c03..aa18f4d 100644 --- a/mqjs.c +++ b/mqjs.c @@ -250,7 +250,10 @@ static uint8_t *load_file(const char *filename, int *plen) buf_len = ftell(f); fseek(f, 0, SEEK_SET); buf = malloc(buf_len + 1); - fread(buf, 1, buf_len, f); + if (fread(buf, 1, buf_len, f) != buf_len) { + printf("not read %d bytes\n", buf_len); + exit(1); + } buf[buf_len] = '\0'; fclose(f); if (plen)