Use vector<char> instead of char* and malloc() for images
And fix the associated memory leaks in the process.
Test: fastboot works
Change-Id: I6e41f351ca6cebf79282d30b1eca1506496e0c21
diff --git a/fastboot/fastboot_driver.cpp b/fastboot/fastboot_driver.cpp
index 4a14131..97857d9 100644
--- a/fastboot/fastboot_driver.cpp
+++ b/fastboot/fastboot_driver.cpp
@@ -194,24 +194,19 @@
RetCode FastBootDriver::Download(const std::vector<char>& buf, std::string* response,
std::vector<std::string>* info) {
- return Download(buf.data(), buf.size(), response, info);
-}
-
-RetCode FastBootDriver::Download(const char* buf, uint32_t size, std::string* response,
- std::vector<std::string>* info) {
RetCode ret;
error_ = "";
- if ((size == 0 || size > MAX_DOWNLOAD_SIZE) && !disable_checks_) {
+ if ((buf.size() == 0 || buf.size() > MAX_DOWNLOAD_SIZE) && !disable_checks_) {
error_ = "Buffer is too large or 0 bytes";
return BAD_ARG;
}
- if ((ret = DownloadCommand(size, response, info))) {
+ if ((ret = DownloadCommand(buf.size(), response, info))) {
return ret;
}
// Write the buffer
- if ((ret = SendBuffer(buf, size))) {
+ if ((ret = SendBuffer(buf))) {
return ret;
}