From: Yu Watanabe Date: Sun, 16 Sep 2018 14:46:58 +0000 (+0900) Subject: sd-device: use qsort_safe() (#10099) X-Git-Tag: v240~719 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5485deee6e3b688d30301f7c00798b6f3af188f3;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index 3f7ead268e0..0e3915f96c6 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;