From 56212634d0b17268180de7415f8be9deedc35adc Mon Sep 17 00:00:00 2001 From: Sander Mertens Date: Thu, 7 Nov 2024 10:59:18 -0800 Subject: [PATCH] Fix issue where offset could be applied to NULL in query engine --- distr/flecs.c | 8 -------- src/query/engine/eval_utils.c | 8 -------- 2 files changed, 16 deletions(-) diff --git a/distr/flecs.c b/distr/flecs.c index 6f3703fb9..0e0e3b42d 100644 --- a/distr/flecs.c +++ b/distr/flecs.c @@ -72879,18 +72879,10 @@ void flecs_query_set_iter_this( it->table = table; it->offset = range->offset; it->count = count; -#ifndef FLECS_SANITIZE - it->entities = &ecs_table_entities(table)[it->offset]; - ecs_assert(it->entities != NULL || it->offset == 0, - ECS_INTERNAL_ERROR, NULL); -#else - /* Prevent "applying zero offset to null pointer" sanitizer error. The - * code panics on a bad offset value, but asan doesn't know that. */ it->entities = ecs_table_entities(table); if (it->entities) { it->entities += it->offset; } -#endif } else if (count == 1) { it->count = 1; it->entities = &ctx->vars[0].entity; diff --git a/src/query/engine/eval_utils.c b/src/query/engine/eval_utils.c index 3b178ba56..2efe03326 100644 --- a/src/query/engine/eval_utils.c +++ b/src/query/engine/eval_utils.c @@ -20,18 +20,10 @@ void flecs_query_set_iter_this( it->table = table; it->offset = range->offset; it->count = count; -#ifndef FLECS_SANITIZE - it->entities = &ecs_table_entities(table)[it->offset]; - ecs_assert(it->entities != NULL || it->offset == 0, - ECS_INTERNAL_ERROR, NULL); -#else - /* Prevent "applying zero offset to null pointer" sanitizer error. The - * code panics on a bad offset value, but asan doesn't know that. */ it->entities = ecs_table_entities(table); if (it->entities) { it->entities += it->offset; } -#endif } else if (count == 1) { it->count = 1; it->entities = &ctx->vars[0].entity;