summaryrefslogtreecommitdiffstats
path: root/updater/updater.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'updater/updater.cpp')
-rw-r--r--updater/updater.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/updater/updater.cpp b/updater/updater.cpp
index 47696b80c..0d19e53c4 100644
--- a/updater/updater.cpp
+++ b/updater/updater.cpp
@@ -21,6 +21,8 @@
#include <stdlib.h>
#include <string.h>
+#include <string>
+
#include <android-base/strings.h>
#include <selinux/label.h>
#include <selinux/selinux.h>
@@ -98,12 +100,11 @@ int main(int argc, char** argv) {
return 4;
}
- char* script = reinterpret_cast<char*>(malloc(script_entry->uncompLen+1));
- if (!mzReadZipEntry(&za, script_entry, script, script_entry->uncompLen)) {
+ std::string script(script_entry->uncompLen, '\0');
+ if (!mzReadZipEntry(&za, script_entry, &script[0], script_entry->uncompLen)) {
printf("failed to read script from package\n");
return 5;
}
- script[script_entry->uncompLen] = '\0';
// Configure edify's functions.
@@ -116,7 +117,7 @@ int main(int argc, char** argv) {
Expr* root;
int error_count = 0;
- int error = parse_string(script, &root, &error_count);
+ int error = parse_string(script.c_str(), &root, &error_count);
if (error != 0 || error_count > 0) {
printf("%d parse errors\n", error_count);
return 6;
@@ -196,7 +197,5 @@ int main(int argc, char** argv) {
mzCloseZipArchive(updater_info.package_zip);
}
sysReleaseMap(&map);
- free(script);
-
return 0;
}