]> jfr.im git - solanum.git/commitdiff
Don't cache files that are empty or not files. Avoids crashing on the likes of 'HELP .'
authorStephen Bennett <redacted>
Thu, 21 Jan 2010 16:27:34 +0000 (16:27 +0000)
committerStephen Bennett <redacted>
Thu, 21 Jan 2010 16:27:34 +0000 (16:27 +0000)
src/cache.c

index 58a2f8e4ddfbfb5350bc6493e8108e16d40ccc2e..c8210504f74ab7b17377cb14802cc8224e6c36bb 100644 (file)
@@ -143,6 +143,13 @@ cache_file(const char *filename, const char *shortname, int flags)
                        rb_dlinkAddTailAlloc(emptyline, &cacheptr->contents);
        }
 
+       if (0 == rb_dlink_list_length(&cacheptr->contents))
+       {
+               /* No contents. Don't cache it after all. */
+               rb_free(cacheptr);
+               cacheptr = NULL;
+       }
+
        fclose(in);
        return cacheptr;
 }