From 751b6e646f341e1d201f1a98770470c23db9e6b7 Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 30 Jun 2022 22:38:14 -0400 Subject: [PATCH] Revert "follow-up: use only the memory that's required" This reverts commit 4a0654c70875964fbe769165e04aebe2713cbe34. --- sys/share/cppregex.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/share/cppregex.cpp b/sys/share/cppregex.cpp index 9f95c6274..0e3a7de1a 100644 --- a/sys/share/cppregex.cpp +++ b/sys/share/cppregex.cpp @@ -12,7 +12,7 @@ extern "C" { #include extern const char regex_id[] = "cppregex"; - static char *cppregex_static_buffer = (char *) 0; + static char cppregex_static_buffer[BUFSZ]; struct nhregex { std::unique_ptr re; @@ -41,9 +41,8 @@ extern "C" { const char *regex_error_desc(struct nhregex *re) { if (re->err) { - if (cppregex_static_buffer != 0) - free(cppregex_static_buffer); - cppregex_static_buffer = dupstr(re->err->what()); + Snprintf(cppregex_static_buffer, sizeof cppregex_static_buffer, + "%s", re->err->what()); return cppregex_static_buffer; } else return nullptr;