From 91c62dd70ec09a762542e2835273942f97509c5d Mon Sep 17 00:00:00 2001 From: JF Bastien Date: Mon, 2 May 2016 15:55:07 -0700 Subject: Fix memcpy UB (#422) Can't call memcpy with size of 0 and nullptr init. --- src/wasm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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& init) : offset(offset) { data.swap(init); -- cgit v1.2.3