diff options
author | Ben Chan <benchan@chromium.org> | 2012-07-16 22:23:55 -0700 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-17 08:02:13 +0200 |
commit | 717977d0b5202c1d0a8cf2a16ae0500cc049a821 (patch) | |
tree | 2761633dcce47823adfbfe20ba102c906373787b /src/mm-iface-modem-messaging.c | |
parent | 431b6a0fc5da7e2c339f30b4993fa78bd83cbbe9 (diff) |
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.
Diffstat (limited to 'src/mm-iface-modem-messaging.c')
-rw-r--r-- | src/mm-iface-modem-messaging.c | 10 |
1 files 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, |