From: Pali Rohár Date: Sun, 27 Feb 2022 00:57:38 +0000 (+0100) Subject: libpci: Always call pci_set_name_list_path() in pci_init_name_list_path() X-Git-Tag: v3.8.0~13 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=5f93596f916038bdb611ca5af351e849f9c02d39;p=pciutils.git libpci: Always call pci_set_name_list_path() in pci_init_name_list_path() If pci_init_name_list_path() does not call pci_set_name_list_path() then a->id_file_name variable is NULL and pci_load_name_list() would crash as it tries to do fopen(NULL, ...). If libpci was configured at compile time to use current executable path for locating pci.ids file and it is not possible to determinate current executable path then call pci_set_name_list_path() with just filename without path (this would fallback to the current working directory). --- diff --git a/lib/init.c b/lib/init.c index 463ae84..f997b2b 100644 --- a/lib/init.c +++ b/lib/init.c @@ -208,7 +208,10 @@ pci_init_name_list_path(struct pci_access *a) len = GetModuleFileNameA(NULL, path, MAX_PATH+1); sep = (len > 0) ? strrchr(path, '\\') : NULL; if (len == 0 || len == MAX_PATH+1 || !sep || MAX_PATH-(size_t)(sep+1-path) < sizeof(PCI_IDS)) - free(path); + { + free(path); + pci_set_name_list_path(a, PCI_IDS, 0); + } else { memcpy(sep+1, PCI_IDS, sizeof(PCI_IDS));