Fix: missing return value check in notification serialization
[lttng-tools.git] / src / common / notification.c
index 3826534cda89e3833e75cba2311020388744adb3..e32737dce89ce94d5c4e7c58e06ef16fee92a063 100644 (file)
@@ -40,13 +40,12 @@ struct lttng_notification *lttng_notification_create(
 
        notification->condition = condition;
        notification->evaluation = evaluation;
-       notification->owns_elements = false;
 end:
        return notification;
 }
 
 LTTNG_HIDDEN
-int lttng_notification_serialize(struct lttng_notification *notification,
+int lttng_notification_serialize(const struct lttng_notification *notification,
                struct lttng_dynamic_buffer *buf)
 {
        int ret;
@@ -57,6 +56,9 @@ int lttng_notification_serialize(struct lttng_notification *notification,
        header_offset = buf->size;
        ret = lttng_dynamic_buffer_append(buf, &notification_comm,
                        sizeof(notification_comm));
+       if (ret) {
+               goto end;
+       }
 
        size_before_payload = buf->size;
        ret = lttng_condition_serialize(notification->condition,
@@ -134,7 +136,6 @@ ssize_t lttng_notification_create_from_buffer(
                goto error;
        }
        ret = notification_size;
-       (*notification)->owns_elements = true;
 end:
        return ret;
 error:
@@ -149,10 +150,8 @@ void lttng_notification_destroy(struct lttng_notification *notification)
                return;
        }
 
-       if (notification->owns_elements) {
-               lttng_condition_destroy(notification->condition);
-               lttng_evaluation_destroy(notification->evaluation);
-       }
+       lttng_condition_destroy(notification->condition);
+       lttng_evaluation_destroy(notification->evaluation);
        free(notification);
 }
 
This page took 0.023405 seconds and 4 git commands to generate.