Skip to content

Avoid memcpy of invalid pointer#634

Open
MichaelChirico wants to merge 2 commits intor-dbi:mainfrom
MichaelChirico:patch-4
Open

Avoid memcpy of invalid pointer#634
MichaelChirico wants to merge 2 commits intor-dbi:mainfrom
MichaelChirico:patch-4

Conversation

@MichaelChirico
Copy link
Contributor

See discussion in r-lib/vctrs#1968.

src/base64.c Outdated
if (j + 1 < outlen) {
SEXP rout2 = PROTECT(allocVector(RAWSXP, j));
memcpy(RAW(rout2), RAW(rout), j);
if (j) memcpy(RAW(rout2), RAW_RO(rout), j);
Copy link

@lionel- lionel- Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe wrap this in r_memcpy as in vctrs? There would be much less chance of reintroducing the pattern while changing code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM. although there's a different backsliding risk introduced (enforcing r_memcpy over memcpy), I think the tradeoff still favors reusing the rlang routine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's your preference for how to include it? LinkingTo: rlang and #include <rlang.h>?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants