diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-01-08 23:45:51 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:14:47 +0100 |
commit | a534afa84d1affcc10b6fc7b414d8f9df8307dd3 (patch) | |
tree | 07b020e921cb19aab8d41b10395cee5be13ddbe6 | |
parent | 7db16d2279891d1014999bd3eaa8a9e6c6496e88 (diff) |
sim: handle initialization failures properly
We should't use MM_SIM() on possibly NULL values.
-rw-r--r-- | src/mm-sim.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mm-sim.c b/src/mm-sim.c index f8030094..e6333e01 100644 --- a/src/mm-sim.c +++ b/src/mm-sim.c @@ -33,8 +33,6 @@ #include "mm-log.h" #include "mm-modem-helpers.h" -typedef struct _InitAsyncContext InitAsyncContext; -static void interface_initialization_step (InitAsyncContext *ctx); static void async_initable_iface_init (GAsyncInitableIface *iface); G_DEFINE_TYPE_EXTENDED (MMSim, mm_sim, MM_GDBUS_TYPE_SIM_SKELETON, 0, @@ -889,6 +887,8 @@ load_operator_name (MMSim *self, /*****************************************************************************/ +typedef struct _InitAsyncContext InitAsyncContext; +static void interface_initialization_step (InitAsyncContext *ctx); typedef enum { INITIALIZATION_STEP_FIRST, @@ -926,7 +926,13 @@ mm_sim_new_finish (GAsyncInitable *initable, GAsyncResult *res, GError **error) { - return MM_SIM (g_async_initable_new_finish (initable, res, error)); + GObject *sim; + + sim = g_async_initable_new_finish (initable, res, error); + if (!sim) + return NULL; + + return MM_SIM (sim); } static gboolean |