From faa8ec5c21e685942e5bcafbe74c1f1ce7d54747 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 20 Oct 2020 13:59:02 -0400 Subject: [PATCH] [bindings] Fix CVecTempl clone operation behavior. CVecTempl previously called Vec.clone_from_slice() on a newly-allocated Vec, which immediately panics as [T].clone_from_slice() requires that the Vec/target slice already has the same length as the source slice. This should have been Vec.extend_from_slice() which exhibits the correct behavior. --- lightning-c-bindings/src/c_types/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightning-c-bindings/src/c_types/mod.rs b/lightning-c-bindings/src/c_types/mod.rs index 840bd7a44..191927790 100644 --- a/lightning-c-bindings/src/c_types/mod.rs +++ b/lightning-c-bindings/src/c_types/mod.rs @@ -320,7 +320,7 @@ impl Clone for CVecTempl { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } - res.clone_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); Self::from(res) } } -- 2.39.5