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 343e239585
commit b4c26701c3
1 changed files with 7 additions and 0 deletions

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