From 1686e7a6907ec8750f1560965fd114388bcad702 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 27 Nov 2017 19:13:25 +0000 Subject: [PATCH 2/9] dbus_message_demarshal: Free the loader if we run out of memory Signed-off-by: Simon McVittie --- dbus/dbus-message.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 43b3a9fb..fbe52567 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -5087,7 +5087,7 @@ dbus_message_demarshal (const char *str, int len, DBusError *error) { - DBusMessageLoader *loader; + DBusMessageLoader *loader = NULL; DBusString *buffer; DBusMessage *msg; @@ -5096,7 +5096,7 @@ dbus_message_demarshal (const char *str, loader = _dbus_message_loader_new (); if (loader == NULL) - return NULL; + goto fail_oom; _dbus_message_loader_get_buffer (loader, &buffer, NULL, NULL); @@ -5127,7 +5127,10 @@ dbus_message_demarshal (const char *str, fail_oom: _DBUS_SET_OOM (error); - _dbus_message_loader_unref (loader); + + if (loader != NULL) + _dbus_message_loader_unref (loader); + return NULL; } -- 2.15.0