Do not assume that text is null-terminated as pointed out by Christopher

2007-08-07  Johan Dahlin  <jdahlin@async.com.br>

    * gtk/gtkbuilderparser.c (text): 
    * gtk/gtkcelllayout.c (attributes_text_element): 
    * gtk/gtkliststore.c (list_store_text): 
    Do not assume that text is null-terminated as pointed out by
    Christopher Fergeau


svn path=/trunk/; revision=18592
This commit is contained in:
Johan Dahlin 2007-08-07 21:52:29 +00:00 committed by Johan Dahlin
parent 923a1cf84e
commit 12e1855bba
4 changed files with 28 additions and 9 deletions

View File

@ -1,5 +1,11 @@
2007-08-07 Johan Dahlin <jdahlin@async.com.br>
* gtk/gtkbuilderparser.c (text):
* gtk/gtkcelllayout.c (attributes_text_element):
* gtk/gtkliststore.c (list_store_text):
Do not assume that text is null-terminated as pointed out by
Christopher Fergeau
* gtk/gtkbuilderparser.c (text): Use g_strdup on the translated
string instead of g_strndup() + the length of the untranslated
string. (#461945, Claude Paroz)

View File

@ -908,14 +908,20 @@ text (GMarkupParseContext *context,
{
PropertyInfo *prop_info = (PropertyInfo*)info;
/* text is not guaranteed to be null-terminated */
char *string = g_strndup (text, text_len);
if (prop_info->translatable && text_len)
{
if (prop_info->context)
text = dpgettext (data->domain, prop_info->context, text);
if (prop_info->context)
text = dpgettext (data->domain, prop_info->context, string);
else
text = dgettext (data->domain, text);
text = dgettext (data->domain, string);
g_free (string);
string = g_strdup (text);
}
prop_info->data = g_strdup (text);
prop_info->data = string;
}
}

View File

@ -349,21 +349,25 @@ attributes_text_element (GMarkupParseContext *context,
AttributesSubParserData *parser_data = (AttributesSubParserData*)user_data;
glong l;
gchar *endptr;
gchar *string;
if (!parser_data->attr_name)
return;
errno = 0;
l = strtol (text, &endptr, 0);
if (errno || endptr == text)
string = g_strndup (text, text_len);
l = strtol (string, &endptr, 0);
if (errno || endptr == string)
{
g_set_error (error,
GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_INVALID_VALUE,
"Could not parse integer `%s'",
text);
string);
g_free (string);
return;
}
g_free (string);
gtk_cell_layout_add_attribute (parser_data->cell_layout,
parser_data->renderer,

View File

@ -2188,15 +2188,17 @@ list_store_text (GMarkupParseContext *context,
SubParserData *data = (SubParserData*)user_data;
gint i;
GError *tmp_error = NULL;
gchar *string;
if (!data->is_data)
return;
i = data->row_column - 1;
string = g_strndup (text, text_len);
if (!gtk_builder_value_from_string_type (data->builder,
data->column_types[i],
text,
string,
&data->values[i],
&tmp_error))
{
@ -2208,6 +2210,7 @@ list_store_text (GMarkupParseContext *context,
tmp_error->message);
g_error_free (tmp_error);
}
g_free (string);
}
static const GMarkupParser list_store_parser =