aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Huang <vincenthsw@gmail.com>2020-10-23 15:52:18 +0800
committerGitHub <noreply@github.com>2020-10-23 15:52:18 +0800
commit47043abb639b7da40bfbf4d26c6cf0ae6b471a7d (patch)
tree3824f958fdbe071342db924a0884d6c8db2c90ec
parent9c8fb8cedfd7474c837b75e2daf000754429721c (diff)
parent931b61ffc31aece93517fec3a04dcefea60e5656 (diff)
downloadrmi4utils-47043abb639b7da40bfbf4d26c6cf0ae6b471a7d.tar.gz
Merge pull request #15 from blueue/master
Initialize varibales as NULL to avoid segmentation fault even no allocation as below
-rwxr-xr-xrmi4update/rmi4update.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/rmi4update/rmi4update.cpp b/rmi4update/rmi4update.cpp
index cbb4d30..0eb6c7f 100755
--- a/rmi4update/rmi4update.cpp
+++ b/rmi4update/rmi4update.cpp
@@ -405,6 +405,11 @@ int RMI4Update::ReadFlashConfig()
free(data_temp);
}
+ // Initialize as NULL here to avoid segmentation fault.
+ m_partitionConfig = NULL;
+ m_partitionCore = NULL;
+ m_partitionGuest = NULL;
+
/* parse the config length */
for (i = 2; i < m_blockSize * m_flashConfigLength; i = i + 8)
{
@@ -439,7 +444,7 @@ int RMI4Update::ReadFlashConfig()
if (partition_temp)
free(partition_temp);
-
+
m_fwBlockCount = m_partitionCore ? m_partitionCore->partition_len : 0;
m_configBlockCount = m_partitionConfig ? m_partitionConfig->partition_len : 0;
m_guestBlockCount = m_partitionGuest ? m_partitionGuest->partition_len : 0;