From 9de6212ddaafe9c9509a0e26429c6d83ffad5d38 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Wed, 15 Apr 2020 16:23:11 -0700 Subject: [PATCH] binpac: Remove use of Variable-Length-Arrays Related to https://github.com/zeek/zeek/issues/895 --- tools/binpac/src/pac_regex.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/binpac/src/pac_regex.cc b/tools/binpac/src/pac_regex.cc index 6265c02876..1d01556bd6 100644 --- a/tools/binpac/src/pac_regex.cc +++ b/tools/binpac/src/pac_regex.cc @@ -10,7 +10,7 @@ const char *RegEx::kMatchPrefix = "MatchPrefix"; string escape_char(const string &s) { - char buf[s.length() * 2 + 1]; + char* buf = new char[s.length() * 2 + 1]; int j = 0; for ( int i = 0; i < (int) s.length(); ++i ) { @@ -40,7 +40,9 @@ string escape_char(const string &s) buf[j++] = '\0'; - return string(buf); + string rval = buf; + delete [] buf; + return rval; } RegEx::RegEx(const string &s)