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>
+
* gunixmounts.c (g_unix_is_mount_path_system_internal):
Add /usr/local to list of internal mountpoints
GFileAttributeMatcher *
g_file_attribute_matcher_ref (GFileAttributeMatcher *matcher)
{
- g_return_val_if_fail (matcher != NULL, NULL);
- g_return_val_if_fail (matcher->ref > 0, NULL);
-
- g_atomic_int_inc (&matcher->ref);
-
+ if (matcher)
+ {
+ g_return_val_if_fail (matcher->ref > 0, NULL);
+ g_atomic_int_inc (&matcher->ref);
+ }
return matcher;
}
void
g_file_attribute_matcher_unref (GFileAttributeMatcher *matcher)
{
- g_return_if_fail (matcher != NULL);
- g_return_if_fail (matcher->ref > 0);
-
- if (g_atomic_int_dec_and_test (&matcher->ref))
+ if (matcher)
{
- if (matcher->more_sub_matchers)
- g_array_free (matcher->more_sub_matchers, TRUE);
+ g_return_if_fail (matcher->ref > 0);
- 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);
+ }
}
}
{
guint32 id;
- g_return_val_if_fail (matcher != NULL, FALSE);
g_return_val_if_fail (attribute != NULL && *attribute != '\0', FALSE);
- if (matcher->all)
+ if (matcher == NULL ||
+ matcher->all)
return FALSE;
id = lookup_attribute (attribute);
g_file_attribute_matcher_matches (GFileAttributeMatcher *matcher,
const char *attribute)
{
- g_return_val_if_fail (matcher != NULL, 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)
return TRUE;
int ns_id;
int i;
- g_return_val_if_fail (matcher != NULL, 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)
return TRUE;
{
int i;
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)
{