diff options
author | Yunhee Seo <yuni.seo@samsung.com> | 2024-02-06 15:06:41 +0900 |
---|---|---|
committer | Yunhee Seo <yuni.seo@samsung.com> | 2024-02-06 15:10:35 +0900 |
commit | 4152694f1e0788ae7f74d2c799482ae88489daca (patch) | |
tree | 108b844fb56eaa7e17132244c1c16e2955934fad | |
parent | 4fec93587ad289105225d6b3e77685028717ed63 (diff) | |
download | libsvi-tizen.tar.gz libsvi-tizen.tar.bz2 libsvi-tizen.zip |
vibrator: Add strdup() usage handling codeHEADaccepted/tizen/unified/x/20240214.051939accepted/tizen/unified/20240208.163953tizenaccepted/tizen_unified_xaccepted/tizen_unified
When the strdup() returns NULL, it should be handled properly.
Change-Id: I0f9639b47e804d7d8d2b11826a5227e22c1f95ff
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
-rw-r--r-- | src/vibrator.c | 10 |
1 files changed, 10 insertions, 0 deletions
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 |