From: Derrick Lyndon Pallas Date: Mon, 22 Apr 2019 20:19:14 +0000 (+0000) Subject: Avoid array-bounds error when debug/fortify enabled X-Git-Tag: v5.2.0^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e15954a4bd02641b80f3e5cb9c71d8d80effd001;p=thirdparty%2Fvectorscan.git Avoid array-bounds error when debug/fortify enabled This code causes GCC to error out due to a bounds error with the following set -D_GLIBCXX_DEBUG -D_FORTIFY_SOURCE=2 The solution is to copy via iterator. --- diff --git a/util/expression_path.h b/util/expression_path.h index 3075b4d4..ac4ca97d 100644 --- a/util/expression_path.h +++ b/util/expression_path.h @@ -56,9 +56,8 @@ std::string inferExpressionPath(const std::string &sigFile) { // POSIX variant. // dirname() may modify its argument, so we must make a copy. - std::vector path(sigFile.size() + 1); - memcpy(path.data(), sigFile.c_str(), sigFile.size()); - path[sigFile.size()] = 0; // ensure null termination. + std::vector path(sigFile.begin(), sigFile.end()); + path.push_back(0); // ensure null termination. std::string rv = dirname(path.data()); #else