From 2997904a85714685274d34fc414dfda570ef8ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Wed, 17 Jul 2024 18:42:55 +0300 Subject: [PATCH] Fix double free (#790) --- src/utils.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index 1723ab23..22904d20 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -2,6 +2,7 @@ // Copyright (c) 2009-2022, Intel Corporation // written by Andrey Semin and many others +#include #include #include #include @@ -125,18 +126,24 @@ const char * setColor (const char * colorStr) return colorEnabled ? colorStr : ""; } -std::vector colorTable = { - ASCII_GREEN, - ASCII_YELLOW, - ASCII_MAGENTA, - ASCII_CYAN, - ASCII_BRIGHT_GREEN, - ASCII_BRIGHT_YELLOW, - ASCII_BRIGHT_BLUE, - ASCII_BRIGHT_MAGENTA, - ASCII_BRIGHT_CYAN, - ASCII_BRIGHT_WHITE -}; +template +constexpr auto make_array(N&&... args) -> std::array +{ + return {std::forward(args)...}; +} + +constexpr auto colorTable{make_array( + ASCII_GREEN, + ASCII_YELLOW, + ASCII_MAGENTA, + ASCII_CYAN, + ASCII_BRIGHT_GREEN, + ASCII_BRIGHT_YELLOW, + ASCII_BRIGHT_BLUE, + ASCII_BRIGHT_MAGENTA, + ASCII_BRIGHT_CYAN, + ASCII_BRIGHT_WHITE +)}; size_t currentColor = 0; const char * setNextColor()