summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2022-02-22 12:47:41 +0100
committerAleksander Morgado <aleksander@aleksander.es>2022-02-22 12:56:06 +0100
commit0fa634fbc99c4a3b5bb4b246477dd10add2c2aae (patch)
tree1b75741b2906b93cdf3f2bdeb54853db39929d2e
parent39be867a54a1dbe663c45f65091d1ba2ed43c002 (diff)
downloadlibqmi-0fa634fbc99c4a3b5bb4b246477dd10add2c2aae.tar.gz
libqmi-glib,device: fix leak on unexpected message errors
transaction_complete_and_free() doesn't take ownership of the GError
-rw-r--r--src/libqmi-glib/qmi-device.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/libqmi-glib/qmi-device.c b/src/libqmi-glib/qmi-device.c
index 31db4402..ae9f6912 100644
--- a/src/libqmi-glib/qmi-device.c
+++ b/src/libqmi-glib/qmi-device.c
@@ -1736,6 +1736,14 @@ process_message (QmiMessage *message,
* while we're talking to it. If so, fail the transaction right away without setting the
* message as response, or otherwise the parsers will complain */
if (qmi_message_get_message_id (tr->message) != qmi_message_get_message_id (message)) {
+ g_autoptr(GError) error = NULL;
+
+ error = g_error_new (QMI_CORE_ERROR,
+ QMI_CORE_ERROR_UNEXPECTED_MESSAGE,
+ "Unexpected response of type 0x%04x received matching transaction for request of type 0x%04x",
+ qmi_message_get_message_id (message),
+ qmi_message_get_message_id (tr->message));
+
/* Translate without an explicit context as this message has nothing to do with the
* request. */
trace_message (self, message, FALSE, "response", NULL);
@@ -1744,12 +1752,7 @@ process_message (QmiMessage *message,
qmi_message_get_transaction_id (message),
qmi_message_get_message_id (tr->message),
qmi_message_get_message_id (message));
- transaction_complete_and_free (tr, NULL,
- g_error_new (QMI_CORE_ERROR,
- QMI_CORE_ERROR_UNEXPECTED_MESSAGE,
- "Unexpected response of type 0x%04x received matching transaction for request of type 0x%04x",
- qmi_message_get_message_id (message),
- qmi_message_get_message_id (tr->message)));
+ transaction_complete_and_free (tr, NULL, error);
return;
}