autoconfig: don't call closedir() when opendir() failed

If opendir() fails, return from matchDriverFromFiles() immediately.
Ubuntu bug 217647.
This commit is contained in:
Julien Cristau 2008-04-22 23:50:11 +02:00
parent 76381092e8
commit fbad87f2ae

View File

@ -330,7 +330,9 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
int i, j; int i, j;
idsdir = opendir(PCI_TXT_IDS_PATH); idsdir = opendir(PCI_TXT_IDS_PATH);
if (idsdir) { if (!idsdir)
return;
xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH); xf86Msg(X_INFO, "Scanning %s directory for additional PCI ID's supported by the drivers\n", PCI_TXT_IDS_PATH);
direntry = readdir(idsdir); direntry = readdir(idsdir);
/* Read the directory */ /* Read the directory */
@ -352,11 +354,11 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
goto end; goto end;
} }
/* Read the file */ /* Read the file */
#ifdef __GLIBC__ #ifdef __GLIBC__
while ((read = getline(&line, &len, fp)) != -1) { while ((read = getline(&line, &len, fp)) != -1) {
#else #else
while ((line = fgetln(fp, &len)) != (char *)NULL) { while ((line = fgetln(fp, &len)) != (char *)NULL) {
#endif /* __GLIBC __ */ #endif /* __GLIBC __ */
xchomp(line); xchomp(line);
if (isdigit(line[0])) { if (isdigit(line[0])) {
strncpy(vendor_str, line, 4); strncpy(vendor_str, line, 4);
@ -408,7 +410,6 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
} }
direntry = readdir(idsdir); direntry = readdir(idsdir);
} }
}
end: end:
xfree(line); xfree(line);
closedir(idsdir); closedir(idsdir);