X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fnames-parse.c;h=1f8925a34f44856c161e0a0b89456518d2bf8ee0;hb=06f9ecf36e529695feea35038e15233dffe37bb7;hp=58ab578e0e9f2d1775fb2f75a7ce49f74bb17155;hpb=a2bf30a4fd407c55e8172e2f6fd158725ccb90b6;p=pciutils.git diff --git a/lib/names-parse.c b/lib/names-parse.c index 58ab578..1f8925a 100644 --- a/lib/names-parse.c +++ b/lib/names-parse.c @@ -3,7 +3,9 @@ * * Copyright (c) 1997--2008 Martin Mares * - * Can be freely distributed and used under the terms of the GNU GPL. + * Can be freely distributed and used under the terms of the GNU GPL v2+. + * + * SPDX-License-Identifier: GPL-2.0-or-later */ #include @@ -30,7 +32,7 @@ static pci_file pci_open(struct pci_access *a) if (result) return result; len = strlen(a->id_file_name); - if (len >= 3 && memcmp(a->id_file_name + len - 3, ".gz", 3) != 0) + if (len < 3 || memcmp(a->id_file_name + len - 3, ".gz", 3) != 0) return result; new_name = malloc(len - 2); memcpy(new_name, a->id_file_name, len - 3); @@ -42,7 +44,7 @@ static pci_file pci_open(struct pci_access *a) #define pci_close(f) gzclose(f) #define PCI_ERROR(f, err) \ if (!err) { \ - int errnum; \ + int errnum = 0; \ gzerror(f, &errnum); \ if (errnum >= 0) err = NULL; \ else if (errnum == Z_ERRNO) err = "I/O error"; \ @@ -221,7 +223,7 @@ pci_load_name_list(struct pci_access *a) const char *err; pci_free_name_list(a); - a->id_load_failed = 1; + a->id_load_attempted = 1; if (!(f = pci_open(a))) return 0; err = id_parse_list(a, f, &lino); @@ -229,7 +231,6 @@ pci_load_name_list(struct pci_access *a) pci_close(f); if (err) a->error("%s at %s, line %d\n", err, a->id_file_name, lino); - a->id_load_failed = 0; return 1; } @@ -238,7 +239,8 @@ pci_free_name_list(struct pci_access *a) { pci_id_cache_flush(a); pci_id_hash_free(a); - a->id_load_failed = 0; + pci_id_hwdb_free(a); + a->id_load_attempted = 0; } void