X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fnames-hwdb.c;h=71e7229470eacfe341fd4a023c9583fe576785f1;hb=e5d1d2dbb64cafd33f9b012b7959b61319dcd250;hp=07b3499b4ee58f406cd8c575ba87ec6b523c6eda;hpb=ac357d3bb8342b2fc22980e0914cdce7758ca310;p=pciutils.git diff --git a/lib/names-hwdb.c b/lib/names-hwdb.c index 07b3499..71e7229 100644 --- a/lib/names-hwdb.c +++ b/lib/names-hwdb.c @@ -4,7 +4,9 @@ * Copyright (c) 2013--2014 Tom Gundersen * Copyright (c) 2014 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 @@ -71,8 +73,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;