[master] Enabled iTXt support by default.
To ensure binary compatibility with
previous versions, the "lang" and "lang_key" members will be assumed
to be omitted from previous versions unless the current libpng
version was built with PNG_iTXt_SUPPORTED (which is otherwise no
longer necessary to gain iTXt support), as a signal that the user has
been building previous versions with PNG_iTXt_SUPPORTED as well.
diff --git a/ANNOUNCE b/ANNOUNCE
index 7764c39..95f44c5 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -92,6 +92,12 @@
Merged libpng-1.2.41.txt with libpng-1.4.0.txt where appropriate.
version 1.2.41beta10 [November 1, 2009]
+ Enabled iTXt support by default. To ensure binary compatibility with
+ previous versions, the "lang" and "lang_key" members will be assumed
+ to be omitted from previous versions unless the current libpng
+ version was built with PNG_iTXt_SUPPORTED (which is otherwise no
+ longer necessary to gain iTXt support), as a signal that the user has
+ been building previous versions with PNG_iTXt_SUPPORTED as well.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
diff --git a/CHANGES b/CHANGES
index ea55e7c..c3f9a6a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2522,6 +2522,12 @@
Merged libpng-1.2.41.txt with libpng-1.4.0.txt where appropriate.
version 1.2.41beta10 [November 1, 2009]
+ Enabled iTXt support by default. To ensure binary compatibility with
+ previous versions, the "lang" and "lang_key" members will be assumed
+ to be omitted from previous versions unless the current libpng
+ version was built with PNG_iTXt_SUPPORTED (which is otherwise no
+ longer necessary to gain iTXt support), as a signal that the user has
+ been building previous versions with PNG_iTXt_SUPPORTED as well.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
diff --git a/libpng-1.2.41beta10.txt b/libpng-1.2.41beta10.txt
index 512faec..2618b76 100644
--- a/libpng-1.2.41beta10.txt
+++ b/libpng-1.2.41beta10.txt
@@ -2950,6 +2950,13 @@
png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(),
png_malloc_default(), and png_free_default() were added.
+Support for the iTXt chunk has been enabled by default as of
+version 1.2.41. If you have been defining PNG_iTXt_SUPPORTED
+already, please continue to do so, as a signal to libpng that your
+previous versions also supported iTXt. If you have not been defining
+PNG_iTXt_SUPPORTED, please don't start now; it will be enabled for
+you by default.
+
Support for certain MNG features was enabled.
Support for numbered error messages was added. However, we never got
diff --git a/pngconf.h b/pngconf.h
index c1fe2ca..fcc024f 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -526,6 +526,18 @@
* will be turned on by default in libpng-1.4.0.
*/
+/* If you have previously been defining PNG_iTXt_SUPPORTED, please
+ * continue to do so in libpng-1.2.41 and later, until you switch to
+ * libpng-1.4.0, even though it is not necessary now to gain iTXt support.
+ * Your PNG_iTXt_SUPPORTED definition will be interpreted in png_set_text()
+ * as a signal that you have defined it in your builds of previous libpng
+ * versions that did not support iTXt by default.
+ */
+#if !defined(PNG_iTXt_SUPPORTED) && !defined(PNG_READ_iTXt_SUPPORTED) && \
+ !defined(PNG_WRITE_iTXt_SUPPORTED)
+# define PNG_iTXt_NOT_PREVIOUSLY_SUPPORTED
+#endif
+
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
# ifndef PNG_iTXt_SUPPORTED
# ifndef PNG_NO_iTXt_SUPPORTED
diff --git a/pngset.c b/pngset.c
index 6841096..b083b91 100644
--- a/pngset.c
+++ b/pngset.c
@@ -653,6 +653,7 @@
int num_text)
{
int i;
+ int caller_no_itxt = 0;
png_debug1(1, "in %s storage function", ((png_ptr == NULL ||
png_ptr->chunk_name[0] == '\0') ?
@@ -661,6 +662,19 @@
if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
return(0);
+#ifdef PNG_iTXt_NOT_PREVIOUSLY_SUPPORTED
+ /* If an earlier version of the library was used to build the
+ * application, it might be using a png_textp structure that
+ * does not contain the lang or lang_key elements. If you build
+ * this library with PNG_iTXt_SUPPORTED explicitly defined,
+ * then we assume that your older library was also built with
+ * PNG_iTXt_SUPPORTED defined and the complete png_textp structure
+ * has existed all along and it's safe to access them. See pngconf.h.
+ */
+ if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
+ caller_no_itxt = 1;
+#endif
+
/* Make sure we have enough space in the "text" array in info_struct
* to hold all of the incoming text_ptr objects.
*/
@@ -721,17 +735,28 @@
#ifdef PNG_iTXt_SUPPORTED
{
/* Set iTXt data */
- if (text_ptr[i].lang != NULL)
- lang_len = png_strlen(text_ptr[i].lang);
- else
- lang_len = 0;
- if (text_ptr[i].lang_key != NULL)
- lang_key_len = png_strlen(text_ptr[i].lang_key);
- else
- lang_key_len = 0;
- }
-#else
+ if (caller_no_itxt == 0)
+ {
+ if (text_ptr[i].lang != NULL)
+ lang_len = png_strlen(text_ptr[i].lang);
+ else
+ lang_len = 0;
+ if (text_ptr[i].lang_key != NULL)
+ lang_key_len = png_strlen(text_ptr[i].lang_key);
+ else
+ lang_key_len = 0;
+ }
+
+ else /* Caller does not support iTXt */
+ {
+ lang_len = 0;
+ lang_key_len = 0;
+ png_warning(png_ptr,
+ "iTXt lang and lang_key not available from application");
+ }
+ }
+#else /* PNG_iTXt_SUPPORTED */
{
png_warning(png_ptr, "iTXt chunk not supported.");
continue;