From 77e6976ac953a7baec0f8499b7fc31d7a5cc7b1c Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Mon, 29 May 2023 10:22:54 -0300 Subject: [PATCH] don't let the string viewer own any references --- r/src/altrep.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/r/src/altrep.cpp b/r/src/altrep.cpp index a6b52fe9b633..ae435d54d6cb 100644 --- a/r/src/altrep.cpp +++ b/r/src/altrep.cpp @@ -743,6 +743,8 @@ struct AltrepVectorString : public AltrepVectorBase> { // Helper class to convert to R strings. We declare one of these for the // class to avoid having to stack-allocate one for every STRING_ELT call. + // This class does not own a reference to any arrays: it is the caller's + // responsibility to ensure the Array lifetime exeeds that of the viewer. struct RStringViewer { RStringViewer() : strip_out_nuls_(false), nul_was_stripped_(false) {} @@ -821,11 +823,11 @@ struct AltrepVectorString : public AltrepVectorBase> { } void SetArray(const std::shared_ptr& array) { - array_ = array; + array_ = array.get(); string_array_ = internal::checked_cast(array.get()); } - std::shared_ptr array_; + const Array* array_; const StringArrayType* string_array_; std::string stripped_string_; bool strip_out_nuls_;