mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-25 00:26:52 +02:00
Avoid a possible NULL dereference (found by Coverity), also avoid some
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.
This commit is contained in:
parent
2ce08609db
commit
d4ac791e02
@ -1,5 +1,9 @@
|
|||||||
2006-04-25 Matthias Clasen <mclasen@redhat.com>
|
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
|
* tests/keyfile-test.c (test_comments): Add a test for
|
||||||
the previous change.
|
the previous change.
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
2006-04-25 Matthias Clasen <mclasen@redhat.com>
|
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
|
* tests/keyfile-test.c (test_comments): Add a test for
|
||||||
the previous change.
|
the previous change.
|
||||||
|
|
||||||
|
@ -1020,13 +1020,19 @@ is_element_full (ParseData *parse_data,
|
|||||||
* namespace has been set, just do a plain comparison between @full_element
|
* namespace has been set, just do a plain comparison between @full_element
|
||||||
* and @element.
|
* and @element.
|
||||||
*/
|
*/
|
||||||
p = g_utf8_strchr (element_full, -1, ':');
|
p = strchr (element_full, ':');
|
||||||
if (p)
|
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
|
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)
|
if (!ns_uri)
|
||||||
{
|
{
|
||||||
/* no default namespace found */
|
/* no default namespace found */
|
||||||
@ -1035,16 +1041,11 @@ is_element_full (ParseData *parse_data,
|
|||||||
return (0 == strcmp (element_full, element));
|
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);
|
resolved = g_strdup_printf ("%s%c%s", ns_uri, sep, element_name);
|
||||||
s = g_strdup_printf ("%s%c%s", namespace, sep, element);
|
s = g_strdup_printf ("%s%c%s", namespace, sep, element);
|
||||||
retval = (0 == strcmp (resolved, s));
|
retval = (0 == strcmp (resolved, s));
|
||||||
|
|
||||||
g_free (ns_name);
|
g_free (ns_name);
|
||||||
g_free (ns_uri);
|
|
||||||
g_free (element_name);
|
|
||||||
g_free (resolved);
|
g_free (resolved);
|
||||||
g_free (s);
|
g_free (s);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user