Skip to content

Commit 61274e8

Browse files
#1597 Fix ubsan applying offset to null error
1 parent 6035499 commit 61274e8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

distr/flecs.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -4609,7 +4609,11 @@ bool ecs_each_next(
46094609
it->table = table;
46104610
it->count = ecs_table_count(table);
46114611
it->entities = ecs_table_entities(table);
4612-
it->ids = &table->type.array[next->index];
4612+
if (next->index != -1) {
4613+
it->ids = &table->type.array[next->index];
4614+
} else {
4615+
it->ids = NULL;
4616+
}
46134617
it->trs = &each_iter->trs;
46144618
it->sources = &each_iter->sources;
46154619
it->sizes = &each_iter->sizes;

src/each.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ bool ecs_each_next(
5555
it->table = table;
5656
it->count = ecs_table_count(table);
5757
it->entities = ecs_table_entities(table);
58-
it->ids = &table->type.array[next->index];
58+
if (next->index != -1) {
59+
it->ids = &table->type.array[next->index];
60+
} else {
61+
it->ids = NULL;
62+
}
5963
it->trs = &each_iter->trs;
6064
it->sources = &each_iter->sources;
6165
it->sizes = &each_iter->sizes;

0 commit comments

Comments
 (0)