PPaste!

wtf

Home - All the pastes - Authored by Thooms

Raw version

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
diff --git a/src/lib.rs b/src/lib.rs
index 2668ba4..90f3d08 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -86,7 +86,9 @@ mod tests {
             let field = core::avro_str_from_c_str(field_str.as_ptr());
 
             let foo_str = CString::new("foo").unwrap();
-            let foo = core::avro_str_from_c_str(foo_str.as_ptr());
+            let foo_str_ptr = foo_str.as_ptr();
+            ::std::mem::forget(foo_str);
+            let foo = core::avro_str_from_c_str(foo_str_ptr);
             let foo_value = types::avro_value_string_new(foo);
 
             let record = types::avro_record_new(schema);
diff --git a/src/types.rs b/src/types.rs
index 7915877..b00fbea 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -13,7 +13,7 @@ pub struct AvroValue;
 #[no_mangle]
 pub unsafe extern "C" fn avro_value_free(v: *mut AvroValue) {
     if !v.is_null() {
-        Box::from_raw(v);
+        Box::from_raw(v as *mut Value);
     }
 }