diff --git a/src/fmpi_futhark.c b/src/fmpi_futhark.c
index 8233ac2699502b86d7ae621c390e2d2d409087ac..dc76a124efc15f67c4d0de5141fffd5fbeef651a 100644
--- a/src/fmpi_futhark.c
+++ b/src/fmpi_futhark.c
@@ -201,6 +201,7 @@ int fmpi_futhark_free_data_sync(
 ){
     assert(ctx != NULL);
     assert(data != NULL);
+    assert(dim_cnt <= FMPI_DIM_MAX);
     const size_t idx = FMPI_PRIV_FUTHARK_FUNC_IDX(dim_cnt, type);
     fmpi_futhark_free_data_func_list[idx](ctx, data);
     fmpi_futhark_sync(ctx);
@@ -216,6 +217,7 @@ int fmpi_futhark_free_data_async(
 ){
     assert(ctx != NULL);
     assert(data != NULL);
+    assert(dim_cnt <= FMPI_DIM_MAX);
     const size_t idx = FMPI_PRIV_FUTHARK_FUNC_IDX(dim_cnt, type);
     return fmpi_futhark_free_data_func_list[idx](ctx, data);
 }