Clean up some buffer allocations
While investigating some memory corruption, I found two bugs: the
backing store the SMBIOS data gets loaded into was left uninitialized,
and the buffer used for the version check was allocated using a pointer
where a size should have been used instead.
Tested: While I can not say for sure this solves the corruption, it
seems to make it much less frequent, during my testing. I am not saying
it is gone, but I can no longer reproduce it.
Change-Id: Ic5d28a0d55cfb179c1bd73e95df2a6bf119f6d8c
Signed-off-by: Josh Lehan <krellan@google.com>
diff --git a/src/mdrv2.cpp b/src/mdrv2.cpp
index 73cc306..383709b 100644
--- a/src/mdrv2.cpp
+++ b/src/mdrv2.cpp
@@ -697,7 +697,8 @@
{
const std::string anchorString21 = "_SM_";
const std::string anchorString30 = "_SM3_";
- std::string buffer(dataIn, dataIn + smbiosTableStorageSize);
+ std::string buffer(reinterpret_cast<const char*>(dataIn),
+ smbiosTableStorageSize);
auto it = std::search(std::begin(buffer), std::end(buffer),
std::begin(anchorString21), std::end(anchorString21));