mirror of https://github.com/GNOME/gimp.git
use g_strndup() instead of g_strdup() if a length was passed.
2004-11-22 Michael Natterer <mitch@gimp.org> * libgimpbase/gimputils.c (gimp_any_to_utf8): use g_strndup() instead of g_strdup() if a length was passed. * app/dialogs/info-window.c: g_strndup() the comment parasite's data and pass -1 as length to gimp_any_to_utf8() so we don't encounter the questionable (buggy?) behavior of g_utf8_validate() to fail upon finding '\0' within the "length" passed. Fixes bug #159051.
This commit is contained in:
parent
88b3cb7df2
commit
20ac70e76f
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2004-11-22 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimpbase/gimputils.c (gimp_any_to_utf8): use g_strndup()
|
||||
instead of g_strdup() if a length was passed.
|
||||
|
||||
* app/dialogs/info-window.c: g_strndup() the comment parasite's
|
||||
data and pass -1 as length to gimp_any_to_utf8() so we don't
|
||||
encounter the questionable (buggy?) behavior of g_utf8_validate()
|
||||
to fail upon finding '\0' within the "length" passed.
|
||||
Fixes bug #159051.
|
||||
|
||||
2004-11-22 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* plug-ins/common/struc.c: applied patch from Wolfgang Hofer
|
||||
|
|
|
@ -220,6 +220,7 @@ info_window_create_comment (InfoDialog *info_win,
|
|||
GtkWidget *vbox;
|
||||
GtkWidget *vbox2;
|
||||
GimpParasite *comment;
|
||||
gchar *utf8;
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 12);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
|
||||
|
@ -234,11 +235,22 @@ info_window_create_comment (InfoDialog *info_win,
|
|||
|
||||
/* image comment */
|
||||
comment = gimp_image_parasite_find (gdisp->gimage, "gimp-comment");
|
||||
if (comment == NULL)
|
||||
g_snprintf (iwd->comment_str, MAX_BUF, "%s", _("(none)"));
|
||||
|
||||
if (comment)
|
||||
{
|
||||
gchar *str = g_strndup (gimp_parasite_data (comment),
|
||||
gimp_parasite_data_size (comment));
|
||||
|
||||
utf8 = gimp_any_to_utf8 (str, -1, NULL);
|
||||
}
|
||||
else
|
||||
g_snprintf (iwd->comment_str, MAX_BUF, "%s",
|
||||
gimp_any_to_utf8 (comment->data, comment->size, NULL));
|
||||
{
|
||||
utf8 = g_strdup (_("(none)"));
|
||||
}
|
||||
|
||||
g_snprintf (iwd->comment_str, MAX_BUF, "%s", utf8);
|
||||
|
||||
g_free (utf8);
|
||||
|
||||
label = gtk_label_new (iwd->comment_str);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
||||
|
@ -606,13 +618,25 @@ info_window_update (GimpDisplay *gdisp)
|
|||
/* image comment */
|
||||
{
|
||||
GimpParasite *comment;
|
||||
gchar *utf8;
|
||||
|
||||
comment = gimp_image_parasite_find (gdisp->gimage, "gimp-comment");
|
||||
if (comment == NULL)
|
||||
g_snprintf (iwd->comment_str, MAX_BUF, "%s", _("(none)"));
|
||||
|
||||
if (comment)
|
||||
{
|
||||
gchar *str = g_strndup (gimp_parasite_data (comment),
|
||||
gimp_parasite_data_size (comment));
|
||||
|
||||
utf8 = gimp_any_to_utf8 (str, -1, NULL);
|
||||
}
|
||||
else
|
||||
g_snprintf (iwd->comment_str, MAX_BUF, "%s",
|
||||
gimp_any_to_utf8 (comment->data, comment->size, NULL));
|
||||
{
|
||||
utf8 = g_strdup (_("(none)"));
|
||||
}
|
||||
|
||||
g_snprintf (iwd->comment_str, MAX_BUF, "%s", utf8);
|
||||
|
||||
g_free (utf8);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -136,9 +136,16 @@ gimp_any_to_utf8 (const gchar *str,
|
|||
g_return_val_if_fail (str != NULL, NULL);
|
||||
|
||||
if (g_utf8_validate (str, len, &start_invalid))
|
||||
utf8 = g_strdup (str);
|
||||
{
|
||||
if (len < 0)
|
||||
utf8 = g_strdup (str);
|
||||
else
|
||||
utf8 = g_strndup (str, len);
|
||||
}
|
||||
else
|
||||
utf8 = g_locale_to_utf8 (str, len, NULL, NULL, NULL);
|
||||
{
|
||||
utf8 = g_locale_to_utf8 (str, len, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
if (! utf8)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue