diff --git a/src/api/api.c b/src/api/api.c index b3ae48245..c1baf064b 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -976,6 +976,7 @@ int8_t z_put(const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr, co _z_bytes_from_owned_bytes(opt.attachment)); // Clean-up z_encoding_drop(opt.encoding); + z_bytes_drop(opt.attachment); return ret; } @@ -1139,6 +1140,7 @@ int8_t z_get(const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keyexpr, co } // Clean-up z_encoding_drop(opt.encoding); + z_bytes_drop(opt.attachment); return ret; } @@ -1227,6 +1229,7 @@ int8_t z_query_reply(const z_loaned_query_t *query, const z_loaned_keyexpr_t *ke } // Clean-up z_encoding_drop(opts.encoding); + z_bytes_drop(opts.attachment); return ret; } #endif diff --git a/src/net/query.c b/src/net/query.c index 081524f8e..798dbd2a1 100644 --- a/src/net/query.c +++ b/src/net/query.c @@ -51,7 +51,7 @@ _z_query_t _z_query_create(const _z_value_t *value, const _z_keyexpr_t *key, con memcpy(q._parameters, parameters->start, parameters->len); q._parameters[parameters->len] = 0; q._anyke = (strstr(q._parameters, Z_SELECTOR_QUERY_MATCH) == NULL) ? false : true; - q.attachment = att; + q.attachment._slice = _z_slice_steal((_z_slice_t *)&att._slice); _z_keyexpr_copy(&q._key, key); _z_value_copy(&q._value, value); diff --git a/src/net/reply.c b/src/net/reply.c index 9dfc5c4fb..2dff090e2 100644 --- a/src/net/reply.c +++ b/src/net/reply.c @@ -98,7 +98,7 @@ _z_reply_t _z_reply_create(_z_keyexpr_t keyexpr, z_reply_tag_t tag, _z_id_t id, _z_slice_copy(&sample.payload._slice, payload); sample.kind = kind; sample.timestamp = _z_timestamp_duplicate(timestamp); - sample.attachment = _z_bytes_duplicate(&att); + sample.attachment._slice = _z_slice_steal((_z_slice_t *)&att._slice); // Create sample rc from value reply.data.sample = _z_sample_rc_new_from_val(sample); diff --git a/src/protocol/codec/message.c b/src/protocol/codec/message.c index 3ba5e3216..592323756 100644 --- a/src/protocol/codec/message.c +++ b/src/protocol/codec/message.c @@ -303,7 +303,7 @@ int8_t _z_push_body_decode_extensions(_z_msg_ext_t *extension, void *ctx) { ret = _z_source_info_decode(&pshb->_body._put._commons._source_info, &zbf); break; } - case _Z_MSG_EXT_ENC_ZBUF | 0x03: { + case _Z_MSG_EXT_ENC_ZBUF | 0x03: { // Attachment pshb->_body._put._attachment._slice = extension->_body._zbuf._val._is_alloc ? _z_slice_steal(&extension->_body._zbuf._val) : _z_slice_duplicate(&extension->_body._zbuf._val); @@ -448,7 +448,7 @@ int8_t _z_query_decode_extensions(_z_msg_ext_t *extension, void *ctx) { _z_slice_copy(&msg->_ext_value.payload._slice, &bytes); break; } - case _Z_MSG_EXT_ENC_ZBUF | 0x05: { + case _Z_MSG_EXT_ENC_ZBUF | 0x05: { // Attachment msg->_ext_attachment._slice = extension->_body._zbuf._val._is_alloc ? _z_slice_steal(&extension->_body._zbuf._val) : _z_slice_duplicate(&extension->_body._zbuf._val);