Skip to content

Commit

Permalink
2 typos; overflow chk, mentioned a while ago
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@87078 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
maechler committed Aug 29, 2024
1 parent 81f7e05 commit 8b7b1b7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ void attribute_no_sanitizer_instrumentation R_CheckStack2(size_t extra)
int dummy;
intptr_t usage = R_CStackDir * (R_CStackStart - (uintptr_t)&dummy);

if (INTPTR_MAX - usage < extra)
/* addition would overflow, this is definitely too much */
R_SignalCStackOverflow(INTPTR_MAX);

/* do it this way, as some compilers do usage + extra
in unsigned arithmetic */
usage += extra;
Expand Down Expand Up @@ -2814,10 +2818,10 @@ SEXP R_makeOutOfBoundsError(SEXP x, int subscript, SEXP sindex,
"%s", R_MSG_subs_o_b);
PROTECT(cond);

/* In some cases the 'sbscript' argument is negative, indicating
/* In some cases the 'subscript' argument is negative, indicating
that which subscript is out of bounds is not known. We could
probably do better, but for now report 'subscript' as NA in the
condition objec. */
condition object. */
SEXP ssub = ScalarInteger(subscript >= 0 ? subscript + 1 : NA_INTEGER);
PROTECT(ssub);

Expand Down

0 comments on commit 8b7b1b7

Please sign in to comment.