mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Quiet a "comparison always true" warning in pngstest.c (John Bowler).
This commit is contained in:
committed by
Glenn Randers-Pehrson
parent
0659cddd21
commit
a00ea0aeae
@@ -3173,32 +3173,43 @@ read_one_file(Image *image)
|
||||
{
|
||||
long int cb = ftell(f);
|
||||
|
||||
if (cb > 0 && (unsigned long int)cb < (size_t)~(size_t)0)
|
||||
if (cb > 0)
|
||||
{
|
||||
png_bytep b = voidcast(png_bytep, malloc((size_t)cb));
|
||||
|
||||
if (b != NULL)
|
||||
if ((unsigned long int)cb <= (size_t)~(size_t)0)
|
||||
{
|
||||
rewind(f);
|
||||
png_bytep b = voidcast(png_bytep, malloc((size_t)cb));
|
||||
|
||||
if (fread(b, (size_t)cb, 1, f) == 1)
|
||||
if (b != NULL)
|
||||
{
|
||||
fclose(f);
|
||||
image->input_memory_size = cb;
|
||||
image->input_memory = b;
|
||||
rewind(f);
|
||||
|
||||
if (fread(b, (size_t)cb, 1, f) == 1)
|
||||
{
|
||||
fclose(f);
|
||||
image->input_memory_size = cb;
|
||||
image->input_memory = b;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
free(b);
|
||||
return logclose(image, f, image->file_name,
|
||||
": read failed: ");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
free(b);
|
||||
return logclose(image, f, image->file_name,
|
||||
": read failed: ");
|
||||
}
|
||||
": out of memory: ");
|
||||
}
|
||||
|
||||
else
|
||||
return logclose(image, f, image->file_name,
|
||||
": out of memory: ");
|
||||
": file too big for this architecture: ");
|
||||
/* cb is the length of the file as a (long) and
|
||||
* this is greater than the maximum amount of
|
||||
* memory that can be requested from malloc.
|
||||
*/
|
||||
}
|
||||
|
||||
else if (cb == 0)
|
||||
|
||||
Reference in New Issue
Block a user