From d4b01d35f39f0ae28e595612fbd8ddbcc738376a Mon Sep 17 00:00:00 2001 From: Lohit Agarwalla Date: Fri, 6 Aug 2021 13:00:23 +0530 Subject: [PATCH] Null check for strtok_r Change-Id: Id4349444446f10c28cc1eb6135bd7f4e616a33a0 Signed-off-by: Lohit Agarwalla --- src/account.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/account.c b/src/account.c index 081cf88..6ff7aa0 100644 --- a/src/account.c +++ b/src/account.c @@ -2956,7 +2956,16 @@ static void _account_subscribe_vconf_callback(keynode_t *key, void *user_data) char *ptr = NULL; event_type = strtok_r(msg, ":", &ptr); + if (event_type == NULL) { + ACCOUNT_ERROR("strtok_r() failed"); + goto END; + } + id = strtok_r(NULL, ":", &ptr); + if (id == NULL) { + ACCOUNT_ERROR("strtok_r() failed"); + goto END; + } ACCOUNT_SLOGD("msg(%s), event_type(%s), id(%s)", msg, event_type, id); @@ -2967,6 +2976,7 @@ static void _account_subscribe_vconf_callback(keynode_t *key, void *user_data) if (tmp->account_subscription_callback) tmp->account_subscription_callback(event_msg, account_id, tmp->user_data); +END: _ACCOUNT_FREE(msg); } } -- 2.34.1