summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--udev/lib/libudev-device.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/udev/lib/libudev-device.c b/udev/lib/libudev-device.c
index 65ba6e30d8..b5d42354e5 100644
--- a/udev/lib/libudev-device.c
+++ b/udev/lib/libudev-device.c
@@ -936,8 +936,13 @@ int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath
}
/* trailing number */
- while (isdigit(udev_device->sysname[--len]))
+ while (len > 0 && isdigit(udev_device->sysname[--len]))
udev_device->sysnum = &udev_device->sysname[len];
+
+ /* sysname is completely numeric */
+ if (len == 0)
+ udev_device->sysnum = NULL;
+
return 0;
}