Skip to content

Commit 09a2354

Browse files
jeroenajdavis
authored andcommitted
fix UBSAN problem
1 parent e09a07a commit 09a2354

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/mongoc/mongoc-set.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ mongoc_set_for_each (mongoc_set_t *set,
167167

168168
items_len = set->items_len;
169169

170+
// prevent undefined behavior of memcpy(NULL)
171+
if(items_len == 0)
172+
return;
173+
170174
old_set = (mongoc_set_item_t *)bson_malloc (sizeof (*old_set) * items_len);
171175
memcpy (old_set, set->items, sizeof (*old_set) * items_len);
172176

0 commit comments

Comments
 (0)