Skip to content

Commit 4555d50

Browse files
author
ripley
committed
more sanity checking of arguments using asRbool
git-svn-id: https://svn.r-project.org/R/trunk@87783 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 3471722 commit 4555d50

File tree

8 files changed

+16
-15
lines changed

8 files changed

+16
-15
lines changed

src/main/apply.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* R : A Computer Language for Statistical Data Analysis
3-
* Copyright (C) 2000-2024 The R Core Team
3+
* Copyright (C) 2000-2025 The R Core Team
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -398,7 +398,7 @@ attribute_hidden SEXP do_islistfactor(SEXP call, SEXP op, SEXP args, SEXP rho)
398398
{
399399
checkArity(op, args);
400400
SEXP X = CAR(args);
401-
Rboolean recursive = asLogical(CADR(args));
401+
Rboolean recursive = asRbool(CADR(args), call);
402402
int n = length(X);
403403
if(n == 0 || !isVectorList(X))
404404
return ScalarLogical(FALSE);

src/main/bind.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* R : A Computer Language for Statistical Data Analysis
3-
* Copyright (C) 1997--2024 The R Core Team
3+
* Copyright (C) 1997--2025 The R Core Team
44
* Copyright (C) 2002--2020 The R Foundation
55
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
66
*
@@ -916,8 +916,8 @@ attribute_hidden SEXP do_unlist(SEXP call, SEXP op, SEXP args, SEXP env)
916916
/* by an optional "recursive" argument. */
917917

918918
PROTECT(args = CAR(ans));
919-
Rboolean recurse = asLogical(CADR(ans));
920-
Rboolean usenames = asLogical(CADDR(ans));
919+
Rboolean recurse = asRbool(CADR(ans), call);
920+
Rboolean usenames = asRbool(CADDR(ans), call);
921921
Rboolean lenient = TRUE; // was (implicitly!) FALSE up to R 3.0.1
922922

923923
/* Determine the type of the returned value. */

src/main/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ attribute_hidden SEXP do_traceOnOff(SEXP call, SEXP op, SEXP args, SEXP rho)
103103
prev = trace ? GET_TRACE_STATE : GET_DEBUG_STATE;
104104

105105
if(length(onOff) > 0) {
106-
Rboolean _new = asLogical(onOff);
106+
int _new = asLogical(onOff);
107107
if(_new == TRUE || _new == FALSE)
108108
if(trace) SET_TRACE_STATE(_new);
109109
else SET_DEBUG_STATE(_new);

src/main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@ attribute_hidden SEXP do_browser(SEXP call, SEXP op, SEXP args, SEXP rho)
14351435
if (TYPEOF(expr) == ENVSXP)
14361436
rho = expr;
14371437

1438-
Rboolean ignoreHook = asLogical(CAR(CDR(CDDDR(argList))));
1438+
Rboolean ignoreHook = asRbool(CAR(CDR(CDDDR(argList))), call);
14391439
if (ignoreHook) {
14401440
R_browserRepl(rho);
14411441
UNPROTECT(1); /* argList */

src/main/memory.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* R : A Computer Language for Statistical Data Analysis
3-
* Copyright (C) 1998--2024 The R Core Team.
3+
* Copyright (C) 1998--2025 The R Core Team.
44
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
55
*
66
* This program is free software; you can redistribute it and/or modify
@@ -2040,7 +2040,7 @@ attribute_hidden SEXP do_gctorture(SEXP call, SEXP op, SEXP args, SEXP rho)
20402040
checkArity(op, args);
20412041

20422042
if (isLogical(CAR(args))) {
2043-
Rboolean on = asLogical(CAR(args));
2043+
Rboolean on = asRbool(CAR(args), call);
20442044
if (on == NA_LOGICAL) gap = NA_INTEGER;
20452045
else if (on) gap = 1;
20462046
else gap = 0;
@@ -2358,6 +2358,7 @@ long double *R_allocLD(size_t nelem)
23582358
#elif __GNUC__
23592359
// This is C99, but do not rely on it.
23602360
// Apple clang warns this is gnu extension.
2361+
# pragma clang diagnostic ignored "-Wgnu-offsetof-extensions"
23612362
size_t ld_align = offsetof(struct { char __a; long double __b; }, __b);
23622363
#else
23632364
size_t ld_align = 0x0F; // value of x86_64, known others are 4 or 8

src/main/objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ static SEXP inherits3(SEXP x, SEXP what, SEXP which)
10281028

10291029
if( !isLogical(which) || (LENGTH(which) != 1) )
10301030
error(_("'which' must be a length 1 logical vector"));
1031-
Rboolean isvec = asLogical(which);
1031+
Rboolean isvec = asRbool(which, R_NilValue);
10321032

10331033
if(isvec)
10341034
PROTECT(rval = allocVector(INTSXP, nwhat));
@@ -1231,7 +1231,7 @@ static SEXP R_isMethodsDispatchOn(SEXP onOff)
12311231
R_stdGen_ptr_t old = R_get_standardGeneric_ptr();
12321232
int ival = !NOT_METHODS_DISPATCH_PTR(old);
12331233
if(length(onOff) > 0) {
1234-
Rboolean onOffValue = asLogical(onOff);
1234+
Rboolean onOffValue = asRbool(onOff, R_NilValue);
12351235
if(onOffValue == NA_INTEGER)
12361236
error(_("'onOff' must be TRUE or FALSE"));
12371237
else if(onOffValue == FALSE)

src/main/platform.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* R : A Computer Language for Statistical Data Analysis
3-
* Copyright (C) 1998--2024 The R Core Team
3+
* Copyright (C) 1998--2025 The R Core Team
44
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
55
*
66
* This program is free software; you can redistribute it and/or modify
@@ -318,7 +318,7 @@ attribute_hidden SEXP do_fileshow(SEXP call, SEXP op, SEXP args, SEXP rho)
318318
fn = CAR(args); args = CDR(args);
319319
hd = CAR(args); args = CDR(args);
320320
tl = CAR(args); args = CDR(args);
321-
dl = (Rboolean) asLogical(CAR(args)); args = CDR(args);
321+
dl = asRbool(CAR(args), call); args = CDR(args);
322322
pg = CAR(args);
323323
n = 0; /* -Wall */
324324
if (!isString(fn) || (n = LENGTH(fn)) < 1)

src/main/sysutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* R : A Computer Language for Statistical Data Analysis
3-
* Copyright (C) 1997-2024 The R Core Team
3+
* Copyright (C) 1997-2025 The R Core Team
44
* Copyright (C) 1995-1996 Robert Gentleman and Ross Ihaka
55
*
66
* This program is free software; you can redistribute it and/or modify
@@ -242,7 +242,7 @@ attribute_hidden SEXP do_interactive(SEXP call, SEXP op, SEXP args, SEXP rho)
242242
attribute_hidden SEXP do_tempdir(SEXP call, SEXP op, SEXP args, SEXP env)
243243
{
244244
checkArity(op, args);
245-
Rboolean check = asLogical(CAR(args));
245+
Rboolean check = asRbool(CAR(args), call);
246246
if(check && !R_isWriteableDir(R_TempDir)) {
247247
R_TempDir = NULL;
248248
R_reInitTempDir(/* die_on_fail = */ FALSE);

0 commit comments

Comments
 (0)