Skip to content

Commit ccc89f0

Browse files
committed
Check for null pointer before subsetting
In the list and r_string cases we don't actually set `data_p_`, so we need to check for nullptr Fixes tidyverse/tidyr#1017
1 parent 8cad185 commit ccc89f0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

inst/include/cpp11/r_vector.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ inline typename r_vector<T>::proxy r_vector<T>::operator[](const R_xlen_t pos) c
697697
if (is_altrep_) {
698698
return {data_, pos, nullptr, true};
699699
}
700-
return {data_, pos, &data_p_[pos], false};
700+
return {data_, pos, data_p_ != nullptr ? &data_p_[pos] : nullptr, false};
701701
}
702702

703703
template <typename T>

0 commit comments

Comments
 (0)