Skip to content

Commit

Permalink
Check for too large C objects. Also avoids GCC warnings (currently tr…
Browse files Browse the repository at this point in the history
…iggered

with LTO).


git-svn-id: https://svn.r-project.org/R/trunk@87305 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
kalibera committed Nov 8, 2024
1 parent afe8539 commit 5ad0bcd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -3570,11 +3570,15 @@ void R_chk_free(void *ptr)

void *R_chk_memcpy(void *dest, const void *src, size_t n)
{
if (n >= PTRDIFF_MAX)
error(_("object is too large (%llu bytes)"), (unsigned long long)n);
return n ? memcpy(dest, src, n) : dest;
}

void *R_chk_memset(void *s, int c, size_t n)
{
if (n >= PTRDIFF_MAX)
error(_("object is too large (%llu bytes)"), (unsigned long long)n);
return n ? memset(s, c, n) : s;
}

Expand Down

0 comments on commit 5ad0bcd

Please sign in to comment.