From 4152694f1e0788ae7f74d2c799482ae88489daca Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Tue, 6 Feb 2024 15:06:41 +0900 Subject: [PATCH] vibrator: Add strdup() usage handling code When the strdup() returns NULL, it should be handled properly. Change-Id: I0f9639b47e804d7d8d2b11826a5227e22c1f95ff Signed-off-by: Yunhee Seo --- src/vibrator.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/vibrator.c b/src/vibrator.c index e758c31..86b6ed0 100644 --- a/src/vibrator.c +++ b/src/vibrator.c @@ -291,6 +291,11 @@ check_pattern: converted_pattern = profile->get_strong_buzz(pattern); temp = strdup(profile->str_pattern(converted_pattern)); + if (!temp) { + _E("Failed to get vibration string pattern"); //LCOV_EXCL_LINE + return -ENOMEM; //LCOV_EXCL_LINE + } + data = trim_str(temp); if (!data) { free(temp); //LCOV_EXCL_LINE @@ -374,6 +379,11 @@ static int vibrator_is_supported(int pattern, bool *supported) /* get vibration data */ temp = strdup(profile->str_pattern(pattern)); + if (!temp) { + _E("Failed to get vibration string pattern"); //LCOV_EXCL_LINE + return -ENOMEM; //LCOV_EXCL_LINE + } + data = trim_str(temp); if (!data) { free(temp); //LCOV_EXCL_LINE -- 2.7.4