summaryrefslogtreecommitdiff
path: root/halimpl/utils/phNxpConfig.cpp
diff options
context:
space:
mode:
authorvishal <vishalb.hunashikatti@nxp.com>2019-05-06 17:57:01 +0530
committernxf35421 <sangeetha.agarwal@nxp.com>2019-05-28 15:09:25 +0530
commitd214e8c4cf31ed1a895a7bf373147a90bc196423 (patch)
tree8ca9ea36940d555b75b06c9e94e83e6426b1385e /halimpl/utils/phNxpConfig.cpp
parent97a3b616432c9190f547128dc9e8dc44fc25eb6c (diff)
Fixed coverity warnings
Warnings Fixed: UNINIT_CTOR, NULL_RETURN, NEGATIVE_RETURN, CHECK_RETURN
Diffstat (limited to 'halimpl/utils/phNxpConfig.cpp')
-rwxr-xr-xhalimpl/utils/phNxpConfig.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/halimpl/utils/phNxpConfig.cpp b/halimpl/utils/phNxpConfig.cpp
index 956b2a2..4c2020c 100755
--- a/halimpl/utils/phNxpConfig.cpp
+++ b/halimpl/utils/phNxpConfig.cpp
@@ -85,22 +85,28 @@ namespace {
size_t readConfigFile(const char* fileName, uint8_t** p_data) {
FILE* fd = fopen(fileName, "rb");
+ uint8_t *buffer = NULL;
+ size_t read = 0;
if (fd == nullptr) return 0;
fseek(fd, 0L, SEEK_END);
const size_t file_size = ftell(fd);
rewind(fd);
- uint8_t* buffer = new uint8_t[file_size];
- size_t read = fread(buffer, file_size, 1, fd);
+ if (file_size > 0) {
+ buffer = new uint8_t[file_size];
+ read = fread(buffer, file_size, 1, fd);
+ } else {
+ ALOGE("%s Invalid file size file_size = %zu\n", __func__, file_size);
+ }
fclose(fd);
if (read == 1) {
*p_data = buffer;
return file_size;
}
-
- delete[] buffer;
+ if (buffer)
+ delete[] buffer;
return 0;
}
@@ -442,7 +448,9 @@ bool CNfcConfig::readConfig(const char* name, bool bResetContent) {
** Returns: none
**
*******************************************************************************/
-CNfcConfig::CNfcConfig() : mValidFile(true), state(0) {}
+CNfcConfig::CNfcConfig()
+ : mValidFile(true), config_crc32_(0), config_crc32_rf_(0),
+ config_crc32_tr_(0), state(0) {}
/*******************************************************************************
**