From 717977d0b5202c1d0a8cf2a16ae0500cc049a821 Mon Sep 17 00:00:00 2001 From: Ben Chan Date: Mon, 16 Jul 2012 22:23:55 -0700 Subject: [PATCH] iface-modem-messaging: check if supported storage is allocated before use load_supported_storages may fail, which results in unallocated storage memory. This patch modifies load_initial_sms_parts_from_storages and is_storage_supported to handle that gracefully. --- src/mm-iface-modem-messaging.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mm-iface-modem-messaging.c b/src/mm-iface-modem-messaging.c index 1ab1c133..b294af93 100644 --- a/src/mm-iface-modem-messaging.c +++ b/src/mm-iface-modem-messaging.c @@ -377,9 +377,11 @@ is_storage_supported (GArray *supported, if (preferred == MM_SMS_STORAGE_UNKNOWN) return TRUE; - for (i = 0; i < supported->len; i++) { - if (preferred == g_array_index (supported, MMSmsStorage, i)) - return TRUE; + if (supported) { + for (i = 0; i < supported->len; i++) { + if (preferred == g_array_index (supported, MMSmsStorage, i)) + return TRUE; + } } g_set_error (error, @@ -761,7 +763,7 @@ load_initial_sms_parts_from_storages (EnablingContext *ctx) storage_ctx = get_storage_context (ctx->self); - if (ctx->mem1_storage_index >= storage_ctx->supported_mem1->len) + if (!storage_ctx->supported_mem1 || ctx->mem1_storage_index >= storage_ctx->supported_mem1->len) all_loaded = TRUE; /* We'll skip the 'MT' storage, as that is a combination of 'SM' and 'ME' */ else if (g_array_index (storage_ctx->supported_mem1,