- fseek (fd, 0, SEEK_SET); /* same as rewind(f); */
-
- /* read full file */
-
- VERBOSE (DEBUG, PRINT ("Reading %d bytes\n", size));
- *buffer = calloc (size + 1, 1);
- int len = fread (*buffer, 1, size, fd);
- if (len != size) {
- VERBOSE (WARNING, PRINT ("Can't read full file (%s)\n", filename));
+ if (size == -1) {
+ VERBOSE (WARNING, PRINT ("Can't read file (%s)\n", filename));
+ } else {
+ fseek (fd, 0, SEEK_SET); /* same as rewind(f); */
+
+ /* read full file */
+ VERBOSE (DEBUG, PRINT ("Reading %d bytes\n", size));
+ *buffer = calloc (size + 1, 1);
+ if ((len = fread (*buffer, 1, size, fd)) != size) {
+ VERBOSE (WARNING, PRINT ("Can't read full file (%s)\n", filename));
+ }