From 0b590a2d47578e44c9c9c642e415ccc559c47174 Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:02:10 +0100 Subject: [PATCH] use nng_alloc() for strcat() --- src/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index b987b40f9..1fabe11df 100644 --- a/src/core.c +++ b/src/core.c @@ -1383,12 +1383,13 @@ SEXP rnng_strcat(SEXP a, SEXP b) { const size_t alen = strlen(ap); const size_t blen = strlen(bp); - char *buf = R_alloc(sizeof(char), alen + blen + 1); + char *buf = nng_alloc(alen + blen + 1); memcpy(buf, ap, alen); memcpy(buf + alen, bp, blen + 1); PROTECT(out = Rf_allocVector(STRSXP, 1)); SET_STRING_ELT(out, 0, Rf_mkCharLenCE(buf, alen + blen, CE_NATIVE)); + nng_free(buf, alen + blen + 1); UNPROTECT(1); return out;