- buf = xmalloc(*len);
- fseek(inf, 0L, SEEK_SET);
- fread(buf, 1, *len, inf);
+ if (*len) /* zero length not considered an error */
+ {
+ size_t r;
+ buf = xmalloc(*len);
+ fseek(inf, 0L, SEEK_SET);
+ r = fread(buf, 1, *len, inf);
+ if (r != *len)
+ {
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "short fread of %s", fname);
+ exit(1);
+ }
+ }