Check the number of children of GVariant 05/243205/3
authorMinje Ahn <minje.ahn@samsung.com>
Fri, 4 Sep 2020 02:18:20 +0000 (11:18 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Fri, 4 Sep 2020 02:42:53 +0000 (11:42 +0900)
If there is no external storage mounted, 'GetDeviceList' will return an empty array.
So, added exception handling for this case.

Change-Id: Ia34e8d5ce97629ab35cceb31fd064ff8b955b313
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/common/media-common-system.c

index fa0dc4e..b3a5e9f 100644 (file)
@@ -213,6 +213,12 @@ static int __ms_gdbus_method_sync(const char *dest,
        g_variant_iter_init(&iter, reply_var);
 
        while ((child = g_variant_iter_next_value(&iter))) {
+               if (g_variant_n_children(child) == 0) {
+                       MS_DBG_INFO("There is no external storage mounted..");
+                       g_variant_unref(child);
+                       break;
+               }
+
                g_variant_get_child(child, 9, "i", &state);
                if (state == 0) {
                        g_variant_unref(child);