diff --git a/adaptors/java/src/se_lth_control_realtime_moberg_Moberg.c b/adaptors/java/src/se_lth_control_realtime_moberg_Moberg.c
index fe658b83a163af2c547a1f5711737bc5910eb465..8cd8e4aaff9e42706773b2305e918ad497fa2a2d 100644
--- a/adaptors/java/src/se_lth_control_realtime_moberg_Moberg.c
+++ b/adaptors/java/src/se_lth_control_realtime_moberg_Moberg.c
@@ -139,7 +139,7 @@ static struct channel *channel_get(struct list *list, int index)
 
 static int channel_set(struct list *list, int index, struct channel channel)
 {
-  if (list->capacity < index) {
+  if (list->capacity <= index) {
     int capacity = index + 1;
     void *new = realloc(list->channel, capacity * sizeof(*list->channel));
     if (new) {