diff --git a/sandboxed_api/var_array.h b/sandboxed_api/var_array.h index c0c43a4..41adefe 100644 --- a/sandboxed_api/var_array.h +++ b/sandboxed_api/var_array.h @@ -113,7 +113,7 @@ class Array : public Var, public Pointable { } else { new_addr = malloc(size); if (new_addr) { - memcpy(new_addr, arr_, total_size_); + memcpy(new_addr, arr_, std::min(size, total_size_)); buffer_owned_ = true; } }