aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-08-06 21:58:22 +0200
committerDan Williams <dcbw@redhat.com>2018-08-21 16:50:15 +0000
commitfc41c167ce018ed1ec20c0969b6bd4536113d395 (patch)
tree7c471c0fa61bd270c58ba56eb3312f99133b33bd
parent4ef3623e6396d5e592410b0ce136a9acf559542d (diff)
iface-modem-3gpp,ussd: let send_finish() return a newly allocated string
GTask integration will benefit from this change.
-rw-r--r--src/mm-broadband-modem.c5
-rw-r--r--src/mm-iface-modem-3gpp-ussd.c14
-rw-r--r--src/mm-iface-modem-3gpp-ussd.h6
3 files changed, 13 insertions, 12 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index d1afba4d..301a0758 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -4970,10 +4970,7 @@ modem_3gpp_ussd_send_finish (MMIfaceModem3gppUssd *self,
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
return NULL;
- /* We can return the string as constant because it is owned by the async
- * result, which will be valid during the whole call of its callback, which
- * is when we're actually calling finish() */
- return (const gchar *)g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
+ return g_strdup (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
}
static void modem_3gpp_ussd_context_step (Modem3gppUssdSendContext *ctx);
diff --git a/src/mm-iface-modem-3gpp-ussd.c b/src/mm-iface-modem-3gpp-ussd.c
index 1da9459f..8fb3a413 100644
--- a/src/mm-iface-modem-3gpp-ussd.c
+++ b/src/mm-iface-modem-3gpp-ussd.c
@@ -194,15 +194,17 @@ handle_respond_ready (MMIfaceModem3gppUssd *self,
HandleRespondContext *ctx)
{
GError *error = NULL;
- const gchar *reply;
+ gchar *reply;
- reply = MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (self)->send_finish (self, res,&error);
+ reply = MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (self)->send_finish (self, res, &error);
if (!reply)
g_dbus_method_invocation_take_error (ctx->invocation, error);
- else
+ else {
mm_gdbus_modem3gpp_ussd_complete_respond (ctx->skeleton,
ctx->invocation,
reply);
+ g_free (reply);
+ }
handle_respond_context_free (ctx);
}
@@ -298,15 +300,17 @@ handle_initiate_ready (MMIfaceModem3gppUssd *self,
HandleInitiateContext *ctx)
{
GError *error = NULL;
- const gchar *reply;
+ gchar *reply;
reply = MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (self)->send_finish (self, res, &error);
if (!reply)
g_dbus_method_invocation_take_error (ctx->invocation, error);
- else
+ else {
mm_gdbus_modem3gpp_ussd_complete_initiate (ctx->skeleton,
ctx->invocation,
reply);
+ g_free (reply);
+ }
handle_initiate_context_free (ctx);
}
diff --git a/src/mm-iface-modem-3gpp-ussd.h b/src/mm-iface-modem-3gpp-ussd.h
index 662d555e..846663b2 100644
--- a/src/mm-iface-modem-3gpp-ussd.h
+++ b/src/mm-iface-modem-3gpp-ussd.h
@@ -93,9 +93,9 @@ struct _MMIfaceModem3gppUssd {
const gchar *command,
GAsyncReadyCallback callback,
gpointer user_data);
- const gchar * (* send_finish) (MMIfaceModem3gppUssd *self,
- GAsyncResult *res,
- GError **error);
+ gchar * (* send_finish) (MMIfaceModem3gppUssd *self,
+ GAsyncResult *res,
+ GError **error);
/* Cancel */
void (* cancel) (MMIfaceModem3gppUssd *self,