diff options
author | himta ram <hram@codeaurora.org> | 2018-01-24 09:07:46 +0530 |
---|---|---|
committer | himta ram <hram@codeaurora.org> | 2018-01-25 10:57:21 +0530 |
commit | 99857187cb33428be716f6a10da1e59fef6fb759 (patch) | |
tree | 3e9482eed5794215208e87098c151b0aa6f179ef /jni/ConfFileParser.cpp | |
parent | ee397206894cfb727b8b2ce021f584f737518d17 (diff) | |
download | android_vendor_qcom_opensource_fm-commonsys-99857187cb33428be716f6a10da1e59fef6fb759.tar.gz android_vendor_qcom_opensource_fm-commonsys-99857187cb33428be716f6a10da1e59fef6fb759.tar.bz2 android_vendor_qcom_opensource_fm-commonsys-99857187cb33428be716f6a10da1e59fef6fb759.zip |
FM: Fix static analysis issue.
KW issue Suspicious dereference of pointer 'val' by passing argument 1 to
function 'strlen'before NULL check, fixed by putting null check
Change-Id: I210b40ce8a309b47d7e72b19efc7a8adb1cfbe49
Diffstat (limited to 'jni/ConfFileParser.cpp')
-rw-r--r-- | jni/ConfFileParser.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/jni/ConfFileParser.cpp b/jni/ConfFileParser.cpp index 444d3c3..d270690 100644 --- a/jni/ConfFileParser.cpp +++ b/jni/ConfFileParser.cpp @@ -850,7 +850,8 @@ static char add_key_value_pair unsigned int key_hash_code; unsigned int grp_index; unsigned int key_index; - unsigned key_len, val_len; + unsigned key_len = 0; + unsigned val_len = 0; group *grp = NULL; key_value_pair_list *list = NULL; @@ -885,7 +886,9 @@ static char add_key_value_pair val pair\n"); goto err; } - key_len = strlen(key); + if(key) { + key_len = strlen(key); + } list->key = (char *)malloc(sizeof(char) * (key_len + 1)); if(list->key == NULL) { @@ -893,7 +896,9 @@ static char add_key_value_pair free(list); goto err; } - val_len = strlen(val); + if(val) { + val_len = strlen(val); + } list->value = (char *)malloc(sizeof(char) * (val_len + 1)); if(!list->value) { |