contents = us->data = N_GNEW(statbuf.st_size + 1, char);
fseek(fp, 0, SEEK_SET);
rc = fread(contents, statbuf.st_size, 1, fp);
- contents[statbuf.st_size] = '\0';
- dtinsert(EPSF_contents, us);
- us->must_inline = must_inline;
+ if (rc == 1) {
+ contents[statbuf.st_size] = '\0';
+ dtinsert(EPSF_contents, us);
+ us->must_inline = must_inline;
+ }
+ else {
+ agerr(AGWARN, "couldn't read from epsf file %s\n", str);
+ free(us->data);
+ free(us);
+ us = NULL;
+ }
} else {
agerr(AGWARN, "BoundingBox not found in epsf file %s\n", str);
us = NULL;