From 56e8a1391df12106d5b5193852b9c140d80e7ec1 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Fri, 12 Jul 2024 10:39:12 -0700 Subject: [PATCH] PROTECT() Scalar* objects --- src/frollR.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/frollR.c b/src/frollR.c index 74cc7dd4e..1cb4d05f5 100644 --- a/src/frollR.c +++ b/src/frollR.c @@ -15,7 +15,8 @@ SEXP coerceToRealListR(SEXP obj) { SEXP this_obj = VECTOR_ELT(obj, i); if (!(isReal(this_obj) || isInteger(this_obj) || isLogical(this_obj))) error(_("x must be of type numeric or logical, or a list, data.frame or data.table of such")); - SET_VECTOR_ELT(x, i, coerceAs(this_obj, ScalarReal(NA_REAL), /*copyArg=*/ScalarLogical(false))); // copyArg=false will make type-class match to return as-is, no copy + SET_VECTOR_ELT(x, i, coerceAs(this_obj, PROTECT(ScalarReal(NA_REAL)), /*copyArg=*/PROTECT(ScalarLogical(false)))); // copyArg=false will make type-class match to return as-is, no copy + UNPROTECT(2); // scalar arguments to coerceAs() } UNPROTECT(protecti); return x;