diff options
author | Yabin Cui <yabinc@google.com> | 2015-09-29 18:05:30 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-07 19:21:20 -0800 |
commit | b3edaa98ab2f2cf9533656d266a54251a1222b5a (patch) | |
tree | 73c10ace2ceb693ca7b6d3a2bdfbce332517cdb7 /minadbd/services.cpp | |
parent | ac61bb9852d7e06c0dc3a00eb6d56b03267527d9 (diff) | |
download | bootable_recovery-b3edaa98ab2f2cf9533656d266a54251a1222b5a.zip bootable_recovery-b3edaa98ab2f2cf9533656d266a54251a1222b5a.tar.gz bootable_recovery-b3edaa98ab2f2cf9533656d266a54251a1222b5a.tar.bz2 |
minadbd: use strdup() to create argument for sideload thread.
So sideload thread will not use argument which is to be freed
in the main thread.
Bug: 23968770
Change-Id: I9d6dadc6c33cfbe4b5759382a80fe14cd0d54355
Diffstat (limited to 'minadbd/services.cpp')
-rw-r--r-- | minadbd/services.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/minadbd/services.cpp b/minadbd/services.cpp index dd1fd7c..0eeeb20 100644 --- a/minadbd/services.cpp +++ b/minadbd/services.cpp @@ -44,13 +44,14 @@ void* service_bootstrap_func(void* x) { } static void sideload_host_service(int sfd, void* data) { - const char* args = reinterpret_cast<const char*>(data); + char* args = reinterpret_cast<char*>(data); int file_size; int block_size; if (sscanf(args, "%d:%d", &file_size, &block_size) != 2) { printf("bad sideload-host arguments: %s\n", args); exit(1); } + free(args); printf("sideload-host file size %d block size %d\n", file_size, block_size); @@ -97,7 +98,8 @@ int service_to_fd(const char* name) { // sideload-host). exit(3); } else if (!strncmp(name, "sideload-host:", 14)) { - ret = create_service_thread(sideload_host_service, (void*)(name + 14)); + char* arg = strdup(name + 14); + ret = create_service_thread(sideload_host_service, arg); } if (ret >= 0) { close_on_exec(ret); |