From e15954a4bd02641b80f3e5cb9c71d8d80effd001 Mon Sep 17 00:00:00 2001 From: Derrick Lyndon Pallas Date: Mon, 22 Apr 2019 20:19:14 +0000 Subject: [PATCH] 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. --- util/expression_path.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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