From c84ce6be6a7e2e70c9ab20b60bc7198699690d50 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 17 Aug 2019 14:19:04 -0700 Subject: CatalogueRescan: if opendir() fails, unref fpes, but don't free the cat None of the callers of CatalogueRescan check for failure before accessing the cat pointer so don't free it (especially without clearing the pointer to it in fpe->private), just unref the contents. Can only be triggered if somehow stat() succeeds on the directory, but opendir fails anyway (removed between the calls? permission problem?). Signed-off-by: Alan Coopersmith --- src/fontfile/catalogue.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/fontfile/catalogue.c b/src/fontfile/catalogue.c index 5df01c2..b5c0331 100644 --- a/src/fontfile/catalogue.c +++ b/src/fontfile/catalogue.c @@ -151,14 +151,12 @@ CatalogueRescan (FontPathElementPtr fpe, Bool forceScan) if ((forceScan == FALSE) && (statbuf.st_mtime <= cat->mtime)) return Successful; + CatalogueUnrefFPEs (fpe); + dir = opendir(path); if (dir == NULL) - { - free(cat); return BadFontPath; - } - CatalogueUnrefFPEs (fpe); while (entry = readdir(dir), entry != NULL) { char *name; -- cgit v1.2.3