X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fubus.git;a=blobdiff_plain;f=ubusd.c;fp=ubusd.c;h=f060b380ce4fd442f1d160a0ab383b67fcffe5b8;hp=5409b7f6ae57335423014d6aae0a7ee7650b3816;hb=c09e4f06f0f54be8304fb4459445198920fea32e;hpb=91acde66b963e238aba35fb4f2030a147df84cd4 diff --git a/ubusd.c b/ubusd.c index 5409b7f..f060b38 100644 --- a/ubusd.c +++ b/ubusd.c @@ -32,8 +32,15 @@ static struct ubus_msg_buf *ubus_msg_ref(struct ubus_msg_buf *ub) { - if (ub->refcount == ~0) - return ubus_msg_new(ub->data, ub->len, false); + struct ubus_msg_buf *new_ub; + if (ub->refcount == ~0) { + new_ub = ubus_msg_new(ub->data, ub->len, false); + if (!new_ub) + return NULL; + memcpy(&new_ub->hdr, &ub->hdr, sizeof(struct ubus_msghdr)); + new_ub->fd = ub->fd; + return new_ub; + } ub->refcount++; return ub;