mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
ASan: Fix "null pointer passed for argument declared to never be null". #2925
Arguments passed to xmemdupz() are sometimes NULL, but xmemdupz() has FUNC_ATTR_NONNULL_ALL. Check pointers for NULL before calling xmemdupz(). Resolves #2533.
This commit is contained in:
parent
fa13cc61ce
commit
bfadf5a28b
@ -426,8 +426,12 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err)
|
||||
|
||||
case kObjectTypeString:
|
||||
tv->v_type = VAR_STRING;
|
||||
if (obj.data.string.data == NULL) {
|
||||
tv->vval.v_string = NULL;
|
||||
} else {
|
||||
tv->vval.v_string = xmemdupz(obj.data.string.data,
|
||||
obj.data.string.size);
|
||||
}
|
||||
break;
|
||||
|
||||
case kObjectTypeArray:
|
||||
|
@ -94,13 +94,14 @@ bool msgpack_rpc_to_string(msgpack_object *obj, String *arg)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
if (obj->type == MSGPACK_OBJECT_BIN || obj->type == MSGPACK_OBJECT_STR) {
|
||||
arg->data = xmemdupz(obj->via.bin.ptr, obj->via.bin.size);
|
||||
arg->size = obj->via.bin.size;
|
||||
} else {
|
||||
if (obj->via.bin.ptr == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
arg->data = xmemdupz(obj->via.bin.ptr, obj->via.bin.size);
|
||||
arg->size = obj->via.bin.size;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool msgpack_rpc_to_object(msgpack_object *obj, Object *arg)
|
||||
|
Loading…
Reference in New Issue
Block a user