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/trunk@1060 632fc199-4ca6-4c93-a231-07263d6284db
This commit is contained in:
@@ -491,7 +491,7 @@ void dodecomptest(char *filename)
|
||||
|
||||
if((file=fopen(filename, "rb"))==NULL)
|
||||
_throwunix("opening file");
|
||||
if(fseek(file, 0, SEEK_END)<0 || (srcsize=ftell(file))<0)
|
||||
if(fseek(file, 0, SEEK_END)<0 || (srcsize=ftell(file))==(unsigned long)-1)
|
||||
_throwunix("determining file size");
|
||||
if((srcbuf=(unsigned char *)malloc(srcsize))==NULL)
|
||||
_throwunix("allocating memory");
|
||||
|
||||
Reference in New Issue
Block a user