Skip to content

Commit a4b5501

Browse files
committed
distances: check internal distances NULLity before dereferencing
Closes #705 Signed-off-by: Brice Goglin <[email protected]>
1 parent e1d07cf commit a4b5501

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hwloc/distances.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ hwloc__distances_transform_merge_switch_ports(hwloc_topology_t topology,
13941394
hwloc_uint64_t *values = distances->values;
13951395
unsigned first, i, j, nbobjs = distances->nbobjs;
13961396

1397-
if (strcmp(dist->name, "NVLinkBandwidth")) {
1397+
if (!dist || strcmp(dist->name, "NVLinkBandwidth")) {
13981398
errno = EINVAL;
13991399
return -1;
14001400
}
@@ -1443,7 +1443,7 @@ hwloc__distances_transform_transitive_closure(hwloc_topology_t topology,
14431443
unsigned nbobjs = distances->nbobjs;
14441444
unsigned i, j, k;
14451445

1446-
if (strcmp(dist->name, "NVLinkBandwidth")) {
1446+
if (!dist || strcmp(dist->name, "NVLinkBandwidth")) {
14471447
errno = EINVAL;
14481448
return -1;
14491449
}

0 commit comments

Comments
 (0)