From d06f3da955c5a545e2217ed743551dcdd07695e3 Mon Sep 17 00:00:00 2001 From: Stephen Bennett Date: Thu, 21 Jan 2010 16:27:34 +0000 Subject: [PATCH] Don't cache files that are empty or not files. Avoids crashing on the likes of 'HELP .' --- src/cache.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cache.c b/src/cache.c index 58a2f8e4d..c8210504f 100644 --- a/src/cache.c +++ b/src/cache.c @@ -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; }