Fix: sessiond: notification: use after free of trigger object
[lttng-tools.git] / src / bin / lttng-sessiond / condition-internal.c
index 07b32f86d611367820e743ebea9a754b3ffe064c..50bb6cb1ae89bd340eb4ccc740ea1f539c59ef60 100644 (file)
@@ -135,3 +135,35 @@ unsigned long lttng_condition_hash(const struct lttng_condition *condition)
                abort();
        }
 }
+
+LTTNG_HIDDEN
+struct lttng_condition *lttng_condition_copy(const struct lttng_condition *condition)
+{
+       int ret;
+       struct lttng_payload copy_buffer;
+       struct lttng_condition *copy = NULL;
+
+       lttng_payload_init(&copy_buffer);
+
+       ret = lttng_condition_serialize(condition, &copy_buffer);
+       if (ret < 0) {
+               goto end;
+       }
+
+       {
+               struct lttng_payload_view view =
+                               lttng_payload_view_from_payload(
+                                               &copy_buffer, 0, -1);
+
+               ret = lttng_condition_create_from_payload(
+                               &view, &copy);
+               if (ret < 0) {
+                       copy = NULL;
+                       goto end;
+               }
+       }
+
+end:
+       lttng_payload_reset(&copy_buffer);
+       return copy;
+}
This page took 0.023468 seconds and 4 git commands to generate.