mirror of
https://github.com/neovim/neovim.git
synced 2025-09-20 18:28:19 +00:00
api/helpers: Remove NULL dereference (#6109)
Even though all used compilers can swallow this code, it is still undefined behaviour.
This commit is contained in:

committed by
Justin M. Keyes

parent
2f38ed11c9
commit
6e881872f4
@@ -380,7 +380,7 @@ static inline void typval_encode_list_start(EncodedData *const edata,
|
|||||||
kv_push(edata->stack, ARRAY_OBJ(((Array) {
|
kv_push(edata->stack, ARRAY_OBJ(((Array) {
|
||||||
.capacity = len,
|
.capacity = len,
|
||||||
.size = 0,
|
.size = 0,
|
||||||
.items = xmalloc(len * sizeof(*((Object *)NULL)->data.array.items)),
|
.items = xmalloc(len * sizeof(*((Object)OBJECT_INIT).data.array.items)),
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,7 +422,8 @@ static inline void typval_encode_dict_start(EncodedData *const edata,
|
|||||||
kv_push(edata->stack, DICTIONARY_OBJ(((Dictionary) {
|
kv_push(edata->stack, DICTIONARY_OBJ(((Dictionary) {
|
||||||
.capacity = len,
|
.capacity = len,
|
||||||
.size = 0,
|
.size = 0,
|
||||||
.items = xmalloc(len * sizeof(*((Object *)NULL)->data.dictionary.items)),
|
.items = xmalloc(len * sizeof(
|
||||||
|
*((Object)OBJECT_INIT).data.dictionary.items)),
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user