Don't cache files that are empty or not files. Avoids crashing on the likes of 'HELP .'

This commit is contained in:
Stephen Bennett 2010-01-21 16:27:34 +00:00
parent 641eb2c3c8
commit d06f3da955

View 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;
}