[gdk-pixbuf/gdk-pixbuf-2-24] Fix handling of options when saving pngs
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf/gdk-pixbuf-2-24] Fix handling of options when saving pngs
- Date: Fri, 16 Dec 2011 21:42:08 +0000 (UTC)
commit 23cdf123efacbdaa47e4d73cdc74e5a3356b18b1
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Dec 16 16:38:41 2011 -0500
Fix handling of options when saving pngs
The png loader treats its options in two passes, the first pass
counts and verifies them, the second pass converts text options.
This worked ok when only text was understood, but with the introduction
of compression and icc-profile as supported options, the two loops
can now get out of sync when the text options are not all at the
beginning.
Fix this by skipping non-text options in the second loop, just
as we do in the first loop.
https://bugzilla.gnome.org/show_bug.cgi?id=620911
gdk-pixbuf/io-png.c | 25 ++++++++++++++++++-------
1 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c
index 76f3304..b2032c4 100644
--- a/gdk-pixbuf/io-png.c
+++ b/gdk-pixbuf/io-png.c
@@ -923,11 +923,19 @@ static gboolean real_save_png (GdkPixbuf *pixbuf,
}
if (num_keys > 0) {
+ gchar **kiter = keys;
+ gchar **viter = values;
+
text_ptr = g_new0 (png_text, num_keys);
for (i = 0; i < num_keys; i++) {
+ if (strncmp (*kiter, "tEXt::", 6) != 0) {
+ kiter++;
+ viter++;
+ }
+
text_ptr[i].compression = PNG_TEXT_COMPRESSION_NONE;
- text_ptr[i].key = keys[i] + 6;
- text_ptr[i].text = g_convert (values[i], -1,
+ text_ptr[i].key = *kiter + 6;
+ text_ptr[i].text = g_convert (*viter, -1,
"ISO-8859-1", "UTF-8",
NULL, &text_ptr[i].text_length,
NULL);
@@ -935,7 +943,7 @@ static gboolean real_save_png (GdkPixbuf *pixbuf,
#ifdef PNG_iTXt_SUPPORTED
if (!text_ptr[i].text) {
text_ptr[i].compression = PNG_ITXT_COMPRESSION_NONE;
- text_ptr[i].text = g_strdup (values[i]);
+ text_ptr[i].text = g_strdup (*viter);
text_ptr[i].text_length = 0;
text_ptr[i].itxt_length = strlen (text_ptr[i].text);
text_ptr[i].lang = NULL;
@@ -944,16 +952,19 @@ static gboolean real_save_png (GdkPixbuf *pixbuf,
#endif
if (!text_ptr[i].text) {
+ gint j;
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_BAD_OPTION,
- _("Value for PNG text chunk %s cannot be converted to ISO-8859-1 encoding."), keys[i] + 6);
- num_keys = i;
- for (i = 0; i < num_keys; i++)
- g_free (text_ptr[i].text);
+ _("Value for PNG text chunk %s cannot be converted to ISO-8859-1 encoding."), *kiter + 6);
+ for (j = 0; j < i; j++)
+ g_free (text_ptr[j].text);
g_free (text_ptr);
return FALSE;
}
+
+ kiter++;
+ viter++;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]