From 958939ace1ab37399727d85c0b3d666ffd1f3190 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Sat, 18 Aug 2018 20:55:42 +0200 Subject: [PATCH] Fix destructors on uninitialized structs --- source/ddbus/thin.d | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/ddbus/thin.d b/source/ddbus/thin.d index fa3c8b5..e92ad1f 100644 --- a/source/ddbus/thin.d +++ b/source/ddbus/thin.d @@ -717,6 +717,7 @@ struct Message { dbus_message_unref(msg); } + /// Creates a new iterator and puts in the arguments for calling a method. void build(TS...)(TS args) if (allCanDBus!TS) { DBusMessageIter iter; @@ -793,6 +794,7 @@ struct Message { } } +/// unittest { import dunit.toolkit; @@ -811,11 +813,16 @@ struct Connection { } ~this() { - dbus_connection_unref(conn); + if (conn) { + dbus_connection_unref(conn); + conn = null; + } } void close() { - dbus_connection_close(conn); + if (conn) { + dbus_connection_close(conn); + } } void send(Message msg) {