Fix a couple of issues with return value checking.  JFREAD(), which wraps fread(), will never return -1.  fread() will instead return 0 or a short object count if an error occurs, and ferror() will return 1 in that case.  The second issue was that we were assigning the return value of ftell() to an unsigned long prior to checking the value, so the value would never be < 0 if an error occurred.  It would instead be (unsigned long)-1.


git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.3.x@1061 632fc199-4ca6-4c93-a231-07263d6284db
diff --git a/djpeg.c b/djpeg.c
index e4e8a62..589c580 100644
--- a/djpeg.c
+++ b/djpeg.c
@@ -566,7 +566,7 @@
         exit(EXIT_FAILURE);
       }
       nbytes = JFREAD(input_file, &inbuffer[insize], INPUT_BUF_SIZE);
-      if (nbytes < 0) {
+      if (nbytes < INPUT_BUF_SIZE && ferror(input_file)) {
         if (file_index < argc)
           fprintf(stderr, "%s: can't read from %s\n", progname,
                   argv[file_index]);