diff options
author | mk5004.lee <mk5004.lee@samsung.com> | 2018-07-12 14:14:55 +0900 |
---|---|---|
committer | mk5004.lee <mk5004.lee@samsung.com> | 2018-07-13 10:34:04 +0900 |
commit | d239dd3a98ca573af4f8aa08c9ca30f6f1613df1 (patch) | |
tree | 3cc022c2a736e54ce9fd31b064d647568cceb640 | |
parent | f8c4761b260e73b7a1b860b7becdb29878b2b8ea (diff) | |
download | notification-d239dd3a98ca573af4f8aa08c9ca30f6f1613df1.tar.gz notification-d239dd3a98ca573af4f8aa08c9ca30f6f1613df1.tar.bz2 notification-d239dd3a98ca573af4f8aa08c9ca30f6f1613df1.zip |
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 <mk5004.lee@samsung.com>
-rwxr-xr-x | src/notification_ipc.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/notification_ipc.c b/src/notification_ipc.c index f1dbc1c..40ad1a1 100755 --- a/src/notification_ipc.c +++ b/src/notification_ipc.c @@ -475,28 +475,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) { + NOTIFICATION_ERR("Invalid number to delete"); + return; + } + NOTIFICATION_DBG("Deleted count[%d]", num); + + buf = (int *)malloc(sizeof(int) * num); + if (buf == NULL) { + NOTIFICATION_ERR("Failed to alloc"); + return; + } + + while (g_variant_iter_loop(iter, "(i)", &buf[idx]) && idx < num) { NOTIFICATION_DBG("priv id[%d]", buf[idx]); idx++; } g_variant_iter_free(iter); - NOTIFICATION_DBG("Deleted count[%d]", idx); noti_op = _ipc_create_op(NOTIFICATION_OP_DELETE, idx, buf, idx, NULL); if (noti_op == NULL) { NOTIFICATION_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 */ |