This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git
The following commit(s) were added to refs/heads/main by this push:
new 090b85e7 fix(r): Correct invocation of R_MakeExternalPtr with R NULL
(#841)
090b85e7 is described below
commit 090b85e7de759aca86201396615c3e8dbddb3bb8
Author: Michael Chirico <[email protected]>
AuthorDate: Tue Jan 27 13:30:35 2026 -0800
fix(r): Correct invocation of R_MakeExternalPtr with R NULL (#841)
We recently found some bad code using `R_MakeExternalPtr(p, nullptr,
nullptr)` (C++ "equivalent" of `NULL`) which could trigger a segfault
_via_ `object.size()` of an object including the incorrectly-initialized
externalptr.
https://cran.r-project.org/doc/manuals/r-devel/R-exts.html#External-pointers-and-weak-references-1
`tag` is an `SEXP`, so the R `NULL` is better than the C `NULL`.
cc @randy3k
---
r/src/buffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/r/src/buffer.c b/r/src/buffer.c
index e1ab50da..06b265ff 100644
--- a/r/src/buffer.c
+++ b/r/src/buffer.c
@@ -186,7 +186,7 @@ SEXP nanoarrow_c_buffer_info(SEXP buffer_xptr) {
"type", "data_type", "element_size_bits",
""};
SEXP info = PROTECT(Rf_mkNamed(VECSXP, names));
- SET_VECTOR_ELT(info, 0, R_MakeExternalPtr(buffer->data, NULL, buffer_xptr));
+ SET_VECTOR_ELT(info, 0, R_MakeExternalPtr(buffer->data, R_NilValue,
buffer_xptr));
SET_VECTOR_ELT(info, 1, Rf_ScalarReal((double)buffer->size_bytes));
SET_VECTOR_ELT(info, 2, Rf_ScalarReal((double)buffer->capacity_bytes));
SET_VECTOR_ELT(info, 3, buffer_type_sexp);