Skip to content

Commit a030213

Browse files
committed
Fixed feature_name=
1 parent a397204 commit a030213

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/lightgbm/dataset.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ def group=(group)
6868
def feature_name=(feature_names)
6969
@feature_names = feature_names
7070
c_feature_names = ::FFI::MemoryPointer.new(:pointer, feature_names.size)
71-
c_feature_names.write_array_of_pointer(feature_names.map { |v| ::FFI::MemoryPointer.from_string(v) })
71+
# keep reference to string pointers
72+
str_ptrs = feature_names.map { |v| ::FFI::MemoryPointer.from_string(v) }
73+
c_feature_names.write_array_of_pointer(str_ptrs)
7274
check_result FFI.LGBM_DatasetSetFeatureNames(handle_pointer, c_feature_names, feature_names.size)
7375
end
7476
alias_method :feature_names=, :feature_name=

0 commit comments

Comments
 (0)