summaryrefslogtreecommitdiff
path: root/png.c
diff options
context:
space:
mode:
authorJohn Bowler <jbowler@acm.org>2016-06-08 08:37:20 -0700
committerJohn Bowler <jbowler@acm.org>2016-06-08 08:37:20 -0700
commitd52c8eba998d7e7ecd9f8cf653f3181b02ed9b94 (patch)
tree8f0006d72bd41cbd866d57dcedb4d747b1b2ddb1 /png.c
parentb70b51ba17b1f64ef72c7fd8761c6ea46520a404 (diff)
downloadlibpng-d52c8eba998d7e7ecd9f8cf653f3181b02ed9b94.tar.gz
Compression changes/fixes
Simplified API: change handling of PNG_IMAGE_FLAG_FAST to use PNG_COMPRESSION_HIGH_SPEED, and PNG_COMPRESSION_HIGH otherwise. Compression: add missing break statements that caused some compression settings to fall through to the 'HIGH' setting. Internal: remove png_struct::flags, it only stored the 'library mismatch' flag and that could never be accessed (because immediately after it was set the png_struct, which was on the stack, was eliminated.) Signed-off-by: John Bowler <jbowler@acm.org>
Diffstat (limited to 'png.c')
-rw-r--r--png.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/png.c b/png.c
index eb96a9913..75cb29eeb 100644
--- a/png.c
+++ b/png.c
@@ -175,16 +175,16 @@ png_calculate_crc(png_structrp png_ptr, png_const_voidp ptr, png_size_t length)
/* Check a user supplied version number, called from both read and write
* functions that create a png_struct.
*/
-int
+static int
png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
{
- /* Libpng versions 1.0.0 and later are binary compatible if the version
- * string matches through the second '.'; we must recompile any
- * applications that use any older library version.
- */
-
+ /* Libpng versions 1.0.0 and later are binary compatible if the version
+ * string matches through the second '.'; we must recompile any applications
+ * that use any older library version.
+ */
if (user_png_ver != NULL)
{
+ int library_match = 1;
int i = -1;
int found_dots = 0;
@@ -192,36 +192,36 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
{
i++;
if (user_png_ver[i] != PNG_LIBPNG_VER_STRING[i])
- png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
+ library_match = 0;
if (user_png_ver[i] == '.')
found_dots++;
- } while (found_dots < 2 && user_png_ver[i] != 0 &&
+ } while (library_match && found_dots < 2 && user_png_ver[i] != 0 &&
PNG_LIBPNG_VER_STRING[i] != 0);
- }
- else
- png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
+ if (library_match)
+ return 1; /* Library matches ok */
+ }
- if ((png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) != 0)
- {
+ /* Failure: mismatched library major version number */
#ifdef PNG_WARNINGS_SUPPORTED
+ {
size_t pos = 0;
char m[128];
pos = png_safecat(m, (sizeof m), pos,
"Application built with libpng-");
+ /* This is ok if user_png_ver is NULL, it appends nothing: */
pos = png_safecat(m, (sizeof m), pos, user_png_ver);
pos = png_safecat(m, (sizeof m), pos, " but running with ");
pos = png_safecat(m, (sizeof m), pos, PNG_LIBPNG_VER_STRING);
PNG_UNUSED(pos)
- png_warning(png_ptr, m);
-#endif
- return 0;
+ png_app_warning(png_ptr, m);
}
+#endif
- /* Success return. */
- return 1;
+ return 0; /* Failure */
+ PNG_UNUSED(png_ptr) /* if no warning */
}
/* Generic function to create a png_struct for either read or write - this
@@ -3431,6 +3431,7 @@ png_setting(png_structrp png_ptr, png_uint_32 setting, png_uint_32 parameter,
/* No write options at present */
result = PNG_OPTION_UNSET; /* i.e. ignore it */
+ break;
# endif /* SET_OPTION */
default: