diff options
author | Martin Mares <mj@ucw.cz> | 2021-12-26 21:52:37 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2021-12-26 21:52:37 +0100 |
commit | ae833de28e16a9ec0144befa36affa2f4239a7c1 (patch) | |
tree | 12f28b7c9db17285783aae7174cb46ebf2f566b2 | |
parent | b9927f149785380d3bc6975f43da224be6bb2b08 (diff) | |
download | pciutils-ae833de28e16a9ec0144befa36affa2f4239a7c1.tar.gz |
HWDB: Handle NULL returned by udev_list_entry_get_*
Based on a patch by <lixiaokeng@huawei.com>.
-rw-r--r-- | lib/names-hwdb.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/names-hwdb.c b/lib/names-hwdb.c index 07b3499..171723b 100644 --- a/lib/names-hwdb.c +++ b/lib/names-hwdb.c @@ -71,8 +71,15 @@ pci_id_hwdb_lookup(struct pci_access *a, int cat, int id1, int id2, int id3, int struct udev_list_entry *entry; udev_list_entry_foreach(entry, udev_hwdb_get_properties_list_entry(a->id_udev_hwdb, modalias, 0)) - if (strcmp(udev_list_entry_get_name(entry), key) == 0) - return pci_strdup(a, udev_list_entry_get_value(entry)); + { + const char *entry_name = udev_list_entry_get_name(entry); + if (entry_name && !strcmp(entry_name, key)) + { + const char *entry_value = udev_list_entry_get_value(entry); + if (entry_value) + return pci_strdup(a, entry_value); + } + } } return NULL; |