Skip to content

Commit

Permalink
Fix issue where offset could be applied to NULL in query engine
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Nov 7, 2024
1 parent da61824 commit 5621263
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
8 changes: 0 additions & 8 deletions distr/flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions src/query/engine/eval_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5621263

Please sign in to comment.