Previous patch (revision 1185) for the comments-related segfault was incomplete,...
authorLaurent Monin <geeqie@norz.org>
Thu, 6 Nov 2008 20:01:32 +0000 (20:01 +0000)
committerLaurent Monin <geeqie@norz.org>
Thu, 6 Nov 2008 20:01:32 +0000 (20:01 +0000)
This patch fixes that (and still fixes the case where one searches on
comments and hits a file with keywords but no comments).  Lastly, I would
imagine that there exists a failure mode where one searches for a keyword and
hits a file with a comment but no keyword, and I imagine this patch should fix
that case as well.

Patch by Omari Stephens (aka xsdg).

src/bar_info.c

index aea1ce9..4ac1846 100644 (file)
@@ -463,8 +463,13 @@ gint comment_read(FileData *fd, GList **keywords, gchar **comment)
        if (res1 && (!comment || *comment != comment1)) g_free(comment1);
        if (res2 && (!comment || *comment != comment2)) g_free(comment2);
        
-       // return FALSE on failure
-       if (comment && !*comment)
+       // return FALSE in the following cases:
+       //  - only looking for a comment and didn't find one
+       //  - only looking for keywords and didn't find any
+       //  - looking for either a comment or keywords, but found nothing
+       if ((!keywords && comment   && !*comment)  ||
+           (!comment  && keywords  && !*keywords) ||
+           ( comment  && !*comment &&   keywords && !*keywords))
                return FALSE;
 
        return TRUE;