]> Pileus Git - grits/blobdiff - src/data/grits-http.c
Fix run-time warning when closing NULL dir
[grits] / src / data / grits-http.c
index 8880d7484710186e7534dc85d985a409a8260864..01bc7053b61504f3c6b8981604ec444263b23871 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
+ * Copyright (C) 2009-2011 Andy Spencer <andy753421@gmail.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -249,11 +249,12 @@ GList *grits_http_available(GritsHttp *http,
                const gchar *file;
                gchar *path = _get_cache_path(http, cache);
                GDir  *dir  = g_dir_open(path, 0, NULL);
-               while ((file = g_dir_read_name(dir)))
+               while (dir && (file = g_dir_read_name(dir)))
                        if (g_regex_match(filter_re, file, 0, NULL))
                                files = g_list_prepend(files, g_strdup(file));
                g_free(path);
-               g_dir_close(dir);
+               if (dir)
+                       g_dir_close(dir);
        }
 
        /* Add online files if online */