File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 22// SPDX-FileCopyrightText: Copyright the Vortex contributors
33
44use std:: fmt:: Formatter ;
5- use std:: ops:: Deref ;
65use std:: sync:: Arc ;
76
87use vortex_buffer:: ByteBuffer ;
@@ -145,11 +144,10 @@ pub trait ArrayChildVisitor<'a> {
145144 // * is_nullable & has_validity => Validity::Array (or Validity::AllInvalid)
146145 // * is_nullable & !has_validity => Validity::AllValid
147146 // * !is_nullable => Validity::NonNullable
148- let constant = ConstantArray :: new ( false , len) ;
149- // SAFETY: We extend the lifetime of the dynamically-constructed constant array
150- // to 'a. This is safe because the visitor will not retain references beyond this call,
151- // and the array lives for the scope of this function.
152- let constant_ref: & ' a dyn Array = unsafe { std:: mem:: transmute ( constant. deref ( ) ) } ;
147+ let constant = ConstantArray :: new ( false , len) . to_array ( ) ;
148+ // TODO: This leaks memory but fixes the dangling pointer bug that caused SIGSEGV
149+ let leaked: & ' static ArrayRef = Box :: leak ( Box :: new ( constant) ) ;
150+ let constant_ref: & ' a dyn Array = leaked. as_ref ( ) ;
153151 self . visit_child ( "validity" , constant_ref)
154152 }
155153 Validity :: Array ( array) => {
You can’t perform that action at this time.
0 commit comments