From a0e720494940d9e9c629622cb04c8fea112552e6 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sun, 18 Jun 2023 23:58:05 +0200 Subject: [PATCH] And fixed it correctly. --- src/device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/device.c b/src/device.c index 2636634c3..a49c7f1e0 100644 --- a/src/device.c +++ b/src/device.c @@ -142,7 +142,7 @@ device_add_common(const device_t *d, const device_t *cd, void *p, void *params, void *priv = NULL; int c; - for (c = 0; c <= 256; c++) { + for (c = 0; c < 256; c++) { if (!inst && (devices[c] == (device_t *) d)) { device_log("DEVICE: device already exists!\n"); return (NULL); @@ -150,8 +150,10 @@ device_add_common(const device_t *d, const device_t *cd, void *p, void *params, if (devices[c] == NULL) break; } - if (c >= DEVICE_MAX) + if ((c >= DEVICE_MAX) || (c >= 256)) { fatal("DEVICE: too many devices\n"); + retrn NULL; + } /* Do this so that a chained device_add will not identify the same ID its master device is already trying to assign. */