From b0bb38eace38e89e9bd941efa257acdbdd930a56 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Fri, 12 Jul 2024 10:43:04 -0700 Subject: [PATCH] Other call sites --- src/frollR.c | 6 ++++-- src/gsumm.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/frollR.c b/src/frollR.c index 1cb4d05f5..a777da17b 100644 --- a/src/frollR.c +++ b/src/frollR.c @@ -146,7 +146,8 @@ SEXP frollfunR(SEXP fun, SEXP obj, SEXP k, SEXP fill, SEXP algo, SEXP align, SEX error(_("fill must be a vector of length 1")); if (!isInteger(fill) && !isReal(fill) && !isLogical(fill)) error(_("fill must be numeric or logical")); - double dfill = REAL(PROTECT(coerceAs(fill, ScalarReal(NA_REAL), ScalarLogical(true))))[0]; protecti++; + double dfill = REAL(PROTECT(coerceAs(fill, PROTECT(ScalarReal(NA_REAL)), PROTECT(ScalarLogical(true)))))[0]; protecti++; + UNPROTECT(2); // Scalar* inputs to coerceAs() bool bnarm = LOGICAL(narm)[0]; @@ -258,7 +259,8 @@ SEXP frollapplyR(SEXP fun, SEXP obj, SEXP k, SEXP fill, SEXP align, SEXP rho) { error(_("fill must be a vector of length 1")); if (!isInteger(fill) && !isReal(fill) && !isLogical(fill)) error(_("fill must be numeric or logical")); - double dfill = REAL(PROTECT(coerceAs(fill, ScalarReal(NA_REAL), ScalarLogical(true))))[0]; protecti++; + double dfill = REAL(PROTECT(coerceAs(fill, PROTECT(ScalarReal(NA_REAL)), PROTECT(ScalarLogical(true)))))[0]; protecti++; + UNPROTECT(2); // Scalar* inputs to coerceAs() SEXP ans = PROTECT(allocVector(VECSXP, nk * nx)); protecti++; if (verbose) diff --git a/src/gsumm.c b/src/gsumm.c index ab604d1c6..eb017bc27 100644 --- a/src/gsumm.c +++ b/src/gsumm.c @@ -591,7 +591,8 @@ SEXP gmean(SEXP x, SEXP narmArg) x = PROTECT(coerceVector(x, REALSXP)); protecti++; case REALSXP: { if (INHERITS(x, char_integer64)) { - x = PROTECT(coerceAs(x, /*as=*/ScalarReal(1), /*copyArg=*/ScalarLogical(TRUE))); protecti++; + x = PROTECT(coerceAs(x, /*as=*/PROTECT(ScalarReal(1)), /*copyArg=*/PROTECT(ScalarLogical(TRUE)))); protecti++; + UNPROTECT(2); // Scalar* inputs to coerceAs() } const double *restrict gx = gather(x, &anyNA); ans = PROTECT(allocVector(REALSXP, ngrp)); protecti++;