mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-10 12:55:48 +01:00
Handle NULL attribute matchers safely, as we return this for empty
2008-01-03 Alexander Larsson <alexl@redhat.com> * gfileinfo.c: Handle NULL attribute matchers safely, as we return this for empty attribute matcher strings. svn path=/trunk/; revision=6238
This commit is contained in:
parent
246e2e71a9
commit
491cccf63a
@ -1,3 +1,9 @@
|
|||||||
|
2008-01-03 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
* gfileinfo.c:
|
||||||
|
Handle NULL attribute matchers safely, as we return this
|
||||||
|
for empty attribute matcher strings.
|
||||||
|
|
||||||
2008-01-03 Alexander Larsson <alexl@redhat.com>
|
2008-01-03 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
* gunixmounts.c (g_unix_is_mount_path_system_internal):
|
* gunixmounts.c (g_unix_is_mount_path_system_internal):
|
||||||
|
@ -1926,11 +1926,11 @@ g_file_attribute_matcher_new (const char *attributes)
|
|||||||
GFileAttributeMatcher *
|
GFileAttributeMatcher *
|
||||||
g_file_attribute_matcher_ref (GFileAttributeMatcher *matcher)
|
g_file_attribute_matcher_ref (GFileAttributeMatcher *matcher)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (matcher != NULL, NULL);
|
if (matcher)
|
||||||
g_return_val_if_fail (matcher->ref > 0, NULL);
|
{
|
||||||
|
g_return_val_if_fail (matcher->ref > 0, NULL);
|
||||||
g_atomic_int_inc (&matcher->ref);
|
g_atomic_int_inc (&matcher->ref);
|
||||||
|
}
|
||||||
return matcher;
|
return matcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1945,15 +1945,17 @@ g_file_attribute_matcher_ref (GFileAttributeMatcher *matcher)
|
|||||||
void
|
void
|
||||||
g_file_attribute_matcher_unref (GFileAttributeMatcher *matcher)
|
g_file_attribute_matcher_unref (GFileAttributeMatcher *matcher)
|
||||||
{
|
{
|
||||||
g_return_if_fail (matcher != NULL);
|
if (matcher)
|
||||||
g_return_if_fail (matcher->ref > 0);
|
|
||||||
|
|
||||||
if (g_atomic_int_dec_and_test (&matcher->ref))
|
|
||||||
{
|
{
|
||||||
if (matcher->more_sub_matchers)
|
g_return_if_fail (matcher->ref > 0);
|
||||||
g_array_free (matcher->more_sub_matchers, TRUE);
|
|
||||||
|
|
||||||
g_free (matcher);
|
if (g_atomic_int_dec_and_test (&matcher->ref))
|
||||||
|
{
|
||||||
|
if (matcher->more_sub_matchers)
|
||||||
|
g_array_free (matcher->more_sub_matchers, TRUE);
|
||||||
|
|
||||||
|
g_free (matcher);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1973,10 +1975,10 @@ g_file_attribute_matcher_matches_only (GFileAttributeMatcher *matcher,
|
|||||||
{
|
{
|
||||||
guint32 id;
|
guint32 id;
|
||||||
|
|
||||||
g_return_val_if_fail (matcher != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (attribute != NULL && *attribute != '\0', FALSE);
|
g_return_val_if_fail (attribute != NULL && *attribute != '\0', FALSE);
|
||||||
|
|
||||||
if (matcher->all)
|
if (matcher == NULL ||
|
||||||
|
matcher->all)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
id = lookup_attribute (attribute);
|
id = lookup_attribute (attribute);
|
||||||
@ -2046,9 +2048,12 @@ gboolean
|
|||||||
g_file_attribute_matcher_matches (GFileAttributeMatcher *matcher,
|
g_file_attribute_matcher_matches (GFileAttributeMatcher *matcher,
|
||||||
const char *attribute)
|
const char *attribute)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (matcher != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (attribute != NULL && *attribute != '\0', FALSE);
|
g_return_val_if_fail (attribute != NULL && *attribute != '\0', FALSE);
|
||||||
|
|
||||||
|
/* We return a NULL matcher for an empty match string, so handle this */
|
||||||
|
if (matcher == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (matcher->all)
|
if (matcher->all)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@ -2079,9 +2084,12 @@ g_file_attribute_matcher_enumerate_namespace (GFileAttributeMatcher *matcher,
|
|||||||
int ns_id;
|
int ns_id;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
g_return_val_if_fail (matcher != NULL, FALSE);
|
|
||||||
g_return_val_if_fail (ns != NULL && *ns != '\0', FALSE);
|
g_return_val_if_fail (ns != NULL && *ns != '\0', FALSE);
|
||||||
|
|
||||||
|
/* We return a NULL matcher for an empty match string, so handle this */
|
||||||
|
if (matcher == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (matcher->all)
|
if (matcher->all)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@ -2124,7 +2132,9 @@ g_file_attribute_matcher_enumerate_next (GFileAttributeMatcher *matcher)
|
|||||||
int i;
|
int i;
|
||||||
SubMatcher *sub_matcher;
|
SubMatcher *sub_matcher;
|
||||||
|
|
||||||
g_return_val_if_fail (matcher != NULL, NULL);
|
/* We return a NULL matcher for an empty match string, so handle this */
|
||||||
|
if (matcher == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user