From bfadf5a28b550bf99101c17244d5ea1b926e40c3 Mon Sep 17 00:00:00 2001 From: Florian Walch Date: Tue, 16 Jun 2015 19:56:51 +0300 Subject: 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. --- src/nvim/msgpack_rpc/helpers.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/nvim/msgpack_rpc/helpers.c') diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index acfd3fe94f..473958c765 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -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) { + 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; - } else { - return false; + return true; } - - return true; + return false; } bool msgpack_rpc_to_object(msgpack_object *obj, Object *arg) -- cgit