From d49679e28dae7bcb9beaa5fb749b0cc224d3fefe Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Tue, 25 Sep 2012 15:27:14 -0300 Subject: [PATCH] ofono: fix error handling memory cleanup order. we must cleanup the stringshares only if the ctx was successfully created, that also mean we must cleanup the stringshares before we dispatch the callback. The order was reversed. --- utils/ofono.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/ofono.c b/utils/ofono.c index 5f6466d..ad993eb 100644 --- a/utils/ofono.c +++ b/utils/ofono.c @@ -3250,7 +3250,7 @@ OFono_Pending *ofono_sms_send(const char *number, const char *message, bus_id, m->base.path, OFONO_PREFIX OFONO_MSG_IFACE, "SendMessage"); if (!msg) - goto error; + goto error_setup; if (!dbus_message_append_args(msg, DBUS_TYPE_STRING, &number, DBUS_TYPE_STRING, &message, @@ -3263,11 +3263,12 @@ OFono_Pending *ofono_sms_send(const char *number, const char *message, error_message: dbus_message_unref(msg); +error_setup: + eina_stringshare_del(ctx->destination); + eina_stringshare_del(ctx->message); error: if (cb) cb((void *)data, err, NULL); - eina_stringshare_del(ctx->destination); - eina_stringshare_del(ctx->message); free(ctx); return NULL; } -- 2.7.4