From: mk5004.lee Date: Thu, 12 Jul 2018 05:14:55 +0000 (+0900) Subject: Fixed to allocated memory as many as deleted X-Git-Tag: submit/tizen/20180718.085216~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8c974cd7e480dc91e7f66b14c1abb429cde070b1;p=platform%2Fcore%2Fapi%2Fnotification.git Fixed to allocated memory as many as deleted - case of delete all, an error occurred because size is specified as 100. Change-Id: I817e79c1310664bd03d1a9d30e0a08ed6cbdbfa2 Signed-off-by: mk5004.lee --- diff --git a/src/notification_ipc.c b/src/notification_ipc.c index 34397675..4f249649 100644 --- a/src/notification_ipc.c +++ b/src/notification_ipc.c @@ -464,28 +464,42 @@ static void _delete_single_notify(GVariant *parameters) /* LCOV_EXCL_START */ static void _delete_multiple_notify(GVariant *parameters) { - int buf[100] = {0,}; + int *buf; int idx = 0; + int num; notification_op *noti_op; GVariantIter *iter; uid_t uid; - g_variant_get(parameters, "(a(i)i)", &iter, &uid); - while (g_variant_iter_loop(iter, "(i)", &buf[idx])) { + g_variant_get(parameters, "(a(i)ii)", &iter, &num, &uid); + if (num <= 0) { + ERR("Invalid number to delete"); + return; + } + DBG("Deleted count[%d]", num); + + buf = (int *)malloc(sizeof(int) * num); + if (buf == NULL) { + ERR("Failed to alloc"); + return; + } + + while (g_variant_iter_loop(iter, "(i)", &buf[idx]) && idx < num) { DBG("priv id[%d]", buf[idx]); idx++; } g_variant_iter_free(iter); - DBG("Deleted count[%d]", idx); noti_op = _ipc_create_op(NOTIFICATION_OP_DELETE, idx, buf, idx, NULL); if (noti_op == NULL) { ERR("Failed to create op"); + free(buf); return; } notification_call_changed_cb_for_uid(noti_op, idx, uid); free(noti_op); + free(buf); } /* LCOV_EXCL_STOP */