summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-09-16 16:46:58 +0200
committerGitHub <noreply@github.com>2018-09-16 16:46:58 +0200
commit5485deee6e3b688d30301f7c00798b6f3af188f3 (patch)
tree8a94e8a332a83ce64fb25beb93a63e2c03c8c9de
parentMerge pull request #9928 from yuwata/libudev-cleanups (diff)
downloadsystemd-5485deee6e3b688d30301f7c00798b6f3af188f3.tar.xz
systemd-5485deee6e3b688d30301f7c00798b6f3af188f3.zip
sd-device: use qsort_safe() (#10099)
The number of found devices may be zero. So, let's use qsort_safe(). Follow-up for 0a1665890cec06032a17c16206e9f519ca88446e. Fixes #10096.
-rw-r--r--src/libsystemd/sd-device/device-enumerator.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c
index 3f7ead268e..0e3915f96c 100644
--- a/src/libsystemd/sd-device/device-enumerator.c
+++ b/src/libsystemd/sd-device/device-enumerator.c
@@ -830,7 +830,7 @@ int device_enumerator_scan_devices(sd_device_enumerator *enumerator) {
r = k;
}
- qsort(enumerator->devices, enumerator->n_devices, sizeof(sd_device *), device_compare);
+ qsort_safe(enumerator->devices, enumerator->n_devices, sizeof(sd_device *), device_compare);
enumerator->scan_uptodate = true;
enumerator->type = DEVICE_ENUMERATION_TYPE_DEVICES;
@@ -914,7 +914,7 @@ int device_enumerator_scan_subsystems(sd_device_enumerator *enumerator) {
}
}
- qsort(enumerator->devices, enumerator->n_devices, sizeof(sd_device *), device_compare);
+ qsort_safe(enumerator->devices, enumerator->n_devices, sizeof(sd_device *), device_compare);
enumerator->scan_uptodate = true;
enumerator->type = DEVICE_ENUMERATION_TYPE_SUBSYSTEMS;