2006-04-25 Matthias Clasen <mclasen@redhat.com>
+ * glib/gbookmarkfile.c (is_element_full): Avoid a possible
+ NULL dereference (found by Coverity), also avoid some
+ pointless strdups.
+
* tests/keyfile-test.c (test_comments): Add a test for
the previous change.
2006-04-25 Matthias Clasen <mclasen@redhat.com>
+ * glib/gbookmarkfile.c (is_element_full): Avoid a possible
+ NULL dereference (found by Coverity), also avoid some
+ pointless strdups.
+
* tests/keyfile-test.c (test_comments): Add a test for
the previous change.
* namespace has been set, just do a plain comparison between @full_element
* and @element.
*/
- p = g_utf8_strchr (element_full, -1, ':');
+ p = strchr (element_full, ':');
if (p)
- ns_name = g_strndup (element_full, p - element_full);
+ {
+ ns_name = g_strndup (element_full, p - element_full);
+ element_name = g_utf8_next_char (p);
+ }
else
- ns_name = g_strdup ("default");
+ {
+ ns_name = g_strdup ("default");
+ element_name = element_full;
+ }
- ns_uri = g_strdup (g_hash_table_lookup (parse_data->namespaces, ns_name));
+ ns_uri = g_hash_table_lookup (parse_data->namespaces, ns_name);
if (!ns_uri)
{
/* no default namespace found */
return (0 == strcmp (element_full, element));
}
- p = g_utf8_next_char (p);
- element_name = g_strdup (p);
-
resolved = g_strdup_printf ("%s%c%s", ns_uri, sep, element_name);
s = g_strdup_printf ("%s%c%s", namespace, sep, element);
retval = (0 == strcmp (resolved, s));
g_free (ns_name);
- g_free (ns_uri);
- g_free (element_name);
g_free (resolved);
g_free (s);