summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJF Bastien <github@jfbastien.com>2016-05-02 15:55:07 -0700
committerJF Bastien <github@jfbastien.com>2016-05-02 15:55:07 -0700
commit91c62dd70ec09a762542e2835273942f97509c5d (patch)
tree18eac2609686fea3ea4db5dde865850be661bc16 /src
parent2559cb90937b4b88377a0e17e0725771511a08a7 (diff)
downloadbinaryen-91c62dd70ec09a762542e2835273942f97509c5d.tar.gz
binaryen-91c62dd70ec09a762542e2835273942f97509c5d.tar.bz2
binaryen-91c62dd70ec09a762542e2835273942f97509c5d.zip
Fix memcpy UB (#422)
Can't call memcpy with size of 0 and nullptr init.
Diffstat (limited to 'src')
-rw-r--r--src/wasm.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/wasm.h b/src/wasm.h
index b13011bae..393f0529b 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -1180,7 +1180,7 @@ public:
Segment() {}
Segment(size_t offset, const char *init, size_t size) : offset(offset) {
data.resize(size);
- memcpy(&data[0], init, size);
+ std::copy_n(init, size, data.begin());
}
Segment(size_t offset, std::vector<char>& init) : offset(offset) {
data.swap(init);