From fa21dcb1bff5d533307b163da8d0d8057e61dba4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 2 Feb 2017 20:37:27 -0500 Subject: [PATCH] Fix: only serialize a field if it is set MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/fields.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/formats/ctf/ir/fields.c b/formats/ctf/ir/fields.c index f5b69784..0ad52a02 100644 --- a/formats/ctf/ir/fields.c +++ b/formats/ctf/ir/fields.c @@ -1903,6 +1903,10 @@ int bt_ctf_field_integer_serialize(struct bt_ctf_field *field, struct bt_ctf_field_integer *integer = container_of(field, struct bt_ctf_field_integer, parent); + if (!bt_ctf_field_generic_is_set(field)) { + ret = -1; + goto end; + } retry: ret = ctf_integer_write(&pos->parent, &integer->definition.p); if (ret == -EFAULT) { @@ -1938,6 +1942,10 @@ int bt_ctf_field_floating_point_serialize(struct bt_ctf_field *field, struct bt_ctf_field_floating_point *floating_point = container_of(field, struct bt_ctf_field_floating_point, parent); + if (!bt_ctf_field_generic_is_set(field)) { + ret = -1; + goto end; + } retry: ret = ctf_float_write(&pos->parent, &floating_point->definition.p); if (ret == -EFAULT) { -- 2.34.1