diff options
author | John Bowler <jbowler@acm.org> | 2014-12-16 19:18:06 -0600 |
---|---|---|
committer | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2014-12-16 19:18:06 -0600 |
commit | a00ea0aeaef81de993e438406ef62b05897126dd (patch) | |
tree | 42fb4d21bc09d7ca345b5d1a0e468bda9717083b | |
parent | 0659cddd21c21347b723052194b2c02a14ff1102 (diff) | |
download | libpng-a00ea0aeaef81de993e438406ef62b05897126dd.tar.gz |
[libpng16] Quiet a "comparison always true" warning in pngstest.c (John Bowler).
-rw-r--r-- | ANNOUNCE | 5 | ||||
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | contrib/libtests/pngstest.c | 39 |
3 files changed, 30 insertions, 17 deletions
@@ -1,4 +1,4 @@ -Libpng 1.6.16beta03 - December 15, 2014 +Libpng 1.6.16beta03 - December 17, 2014 This is not intended to be a public release. It will be replaced within a few weeks by a public version or by another test version. @@ -35,7 +35,8 @@ Version 1.6.16beta02 [December 15, 2014] Revised Makefile.am and scripts/*.dfn again to work with MinGW/MSYS; renamed scripts/*.dfn to scripts/*.c (John Bowler). -Version 1.6.16beta03 [December 15, 2014] +Version 1.6.16beta03 [December 17, 2014] + Quiet a "comparison always true" warning in pngstest.c (John Bowler). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit @@ -5109,7 +5109,8 @@ Version 1.6.16beta02 [December 15, 2014] Revised Makefile.am and scripts/*.dfn again to work with MinGW/MSYS; renamed scripts/*.dfn to scripts/*.c (John Bowler). -Version 1.6.16beta03 [December 15, 2014] +Version 1.6.16beta03 [December 17, 2014] + Quiet a "comparison always true" warning in pngstest.c (John Bowler). Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/contrib/libtests/pngstest.c b/contrib/libtests/pngstest.c index d20e8f224..6d6c501ef 100644 --- a/contrib/libtests/pngstest.c +++ b/contrib/libtests/pngstest.c @@ -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) |