[PATCH libXfont] improve error handling on catalogue:<dir> implementation
Ademar de Souza Reis Jr
ademar at mandriva.com.br
Thu Jul 5 14:55:24 PDT 2007
---
src/fontfile/catalogue.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/fontfile/catalogue.c b/src/fontfile/catalogue.c
index 812b050..bc09fcb 100644
--- a/src/fontfile/catalogue.c
+++ b/src/fontfile/catalogue.c
@@ -138,8 +138,10 @@ CatalogueRescan (FontPathElementPtr fpe)
int len;
path = fpe->name + strlen(CataloguePrefix);
- if (stat(path, &statbuf) < 0 || !S_ISDIR(statbuf.st_mode))
+ if (stat(path, &statbuf) < 0 || !S_ISDIR(statbuf.st_mode)) {
+ xfree(cat);
return BadFontPath;
+ }
if (statbuf.st_mtime <= cat->mtime)
return Successful;
@@ -273,7 +275,9 @@ CatalogueOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
FontDirectoryPtr dir;
int i, status;
- CatalogueRescan (fpe);
+ status = CatalogueRescan(fpe);
+ if (status != Successful)
+ return status;
for (i = 0; i < cat->fpeCount; i++)
{
@@ -305,9 +309,11 @@ CatalogueListFonts (pointer client, FontPathElementPtr fpe, char *pat,
CataloguePtr cat = fpe->private;
FontPathElementPtr subfpe;
FontDirectoryPtr dir;
- int i;
+ int i, status;
- CatalogueRescan (fpe);
+ status = CatalogueRescan(fpe);
+ if (status != Successful)
+ return status;
for (i = 0; i < cat->fpeCount; i++)
{
@@ -338,7 +344,9 @@ CatalogueStartListFonts(pointer client, FontPathElementPtr fpe,
LFWIDataPtr data;
int ret, i, j;
- CatalogueRescan (fpe);
+ ret = CatalogueRescan(fpe);
+ if (ret != Successful)
+ return ret;
data = (LFWIDataPtr) xalloc (sizeof *data +
sizeof data->privates[0] * cat->fpeCount);
@@ -363,7 +371,7 @@ CatalogueStartListFonts(pointer client, FontPathElementPtr fpe,
/* FIXME: we have no way to free the per-fpe privates. */;
xfree (data);
- return AllocError;
+ return ret;
}
static int
--
1.5.2.2
More information about the xorg
mailing list