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 22db77f fix(r): Don't memcpy NULL when converting buffer to raw (#149)
22db77f is described below
commit 22db77f17b6bfa789bb346de90ab126630d6ed2d
Author: Dewey Dunnington <[email protected]>
AuthorDate: Tue Mar 7 22:40:31 2023 -0400
fix(r): Don't memcpy NULL when converting buffer to raw (#149)
Closes #148.
---
r/src/buffer.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/r/src/buffer.c b/r/src/buffer.c
index ca808e7..d027a0e 100644
--- a/r/src/buffer.c
+++ b/r/src/buffer.c
@@ -125,7 +125,9 @@ SEXP nanoarrow_c_buffer_as_raw(SEXP buffer_xptr) {
struct ArrowBuffer* buffer = buffer_from_xptr(buffer_xptr);
SEXP result = PROTECT(Rf_allocVector(RAWSXP, buffer->size_bytes));
- memcpy(RAW(result), buffer->data, buffer->size_bytes);
+ if (buffer->size_bytes > 0) {
+ memcpy(RAW(result), buffer->data, buffer->size_bytes);
+ }
UNPROTECT(1);
return result;
}