From c2aa7526ffe5df5db079214f2e65325edd883c02 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sun, 21 Jul 2024 12:42:26 -0700 Subject: [PATCH] Ensure we're not UNPROTECT()ing 'x' --- src/gsumm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gsumm.c b/src/gsumm.c index 7607f4258..f7504291e 100644 --- a/src/gsumm.c +++ b/src/gsumm.c @@ -594,8 +594,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=*/PROTECT(ScalarReal(1)), /*copyArg=*/ScalarLogical(TRUE))); protecti++; - UNPROTECT(1); // as= input to coerceAs() + SEXP as = PROTECT(ScalarReal(1)); + x = PROTECT(coerceAs(x, as, /*copyArg=*/ScalarLogical(TRUE))); protecti+=2; } const double *restrict gx = gather(x, &anyNA); ans = PROTECT(allocVector(REALSXP, ngrp)); protecti++;