ofono: fix error handling memory cleanup order.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Tue, 25 Sep 2012 18:27:14 +0000 (15:27 -0300)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Tue, 25 Sep 2012 19:13:50 +0000 (16:13 -0300)
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

index 5f6466d..ad993eb 100644 (file)
@@ -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;
 }