Don't make zero-sized allocations when cloning modifier sets

This commit is contained in:
Vftdan 2024-08-19 21:14:06 +02:00
parent 399f0b278e
commit 125e2ad5d8
1 changed files with 3 additions and 0 deletions

View File

@ -23,6 +23,9 @@ typedef enum {
__attribute__((unused)) inline static ModifierSet __attribute__((unused)) inline static ModifierSet
modifier_set_copy(const ModifierSet old) modifier_set_copy(const ModifierSet old)
{ {
if (!old.byte_length) {
return EMPTY_MODIFIER_SET;
};
ModifierSet result = old; ModifierSet result = old;
result.bits = malloc(result.byte_length); result.bits = malloc(result.byte_length);
if (!result.bits) { if (!result.bits) {