Fix bug that encoded bundle data is null 48/215448/2
authorInkyun Kil <inkyun.kil@samsung.com>
Tue, 8 Oct 2019 07:48:11 +0000 (16:48 +0900)
committerJusung Son <jusung07.son@samsung.com>
Thu, 10 Oct 2019 23:29:23 +0000 (08:29 +0900)
Change-Id: Ic837ac01eef93a7398a1870653ad336e78793032
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
Signed-off-by: Jusung Son <jusung07.son@samsung.com>
src/esd_main.c

index f5de3ca..9484e89 100644 (file)
@@ -1548,7 +1548,7 @@ out:
 static void get_earlier_data_method_call(GVariant *parameters, GDBusMethodInvocation *invocation)
 {
        GVariant *param = NULL;
-       int result = 0;
+       int result = ES_R_ERROR;
        char *event_name = NULL;
        bundle *b = NULL;
        bundle_raw *raw = NULL;
@@ -1556,25 +1556,23 @@ static void get_earlier_data_method_call(GVariant *parameters, GDBusMethodInvoca
        earlier_item *item;
 
        g_variant_get(parameters, "(&s)", &event_name);
-
-       if (event_name && strlen(event_name) > 0) {
-               _D("event_name(%s)", event_name);
-               result = ES_R_OK;
-       } else {
-               _E("invalid event_name(%s)", event_name);
-               result = ES_R_ERROR;
-       }
+       _D("event_name(%s)", event_name);
 
        item = (earlier_item *)g_hash_table_lookup(earlier_event_table, event_name);
        if (item != NULL) {
                if (item->earlier_data) {
                        b = bundle_dup(item->earlier_data);
                        bundle_add_str(b, "is_earlier_data", "true");
-                       bundle_encode(b, &raw, &len);
-                       bundle_free(b);
+                       result = ES_R_OK;
                }
        }
 
+       if (result == ES_R_ERROR)
+               b = bundle_create();
+
+       bundle_encode(b, &raw, &len);
+       bundle_free(b);
+
        param = g_variant_new("(iis)", result, len, raw);
 
        _D("result(%d), len(%d)", result, len);