1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00

fix(build): UB when converting strings in logger

The memory returned was no longer valid because arg is destructed after
the function returns.
This commit is contained in:
patrick96 2020-12-11 22:10:20 +01:00 committed by Patrick Ziegler
parent d665634484
commit a45b5d0424
2 changed files with 4 additions and 3 deletions

View file

@ -100,7 +100,7 @@ class logger {
/**
* Convert string
*/
const char* convert(string arg) const; // NOLINT
const char* convert(const string& arg) const;
/**
* Convert thread id

View file

@ -1,6 +1,7 @@
#include "components/logger.hpp"
#include <unistd.h>
#include "components/logger.hpp"
#include "errors.hpp"
#include "settings.hpp"
#include "utils/concurrency.hpp"
@ -12,7 +13,7 @@ POLYBAR_NS
/**
* Convert string
*/
const char* logger::convert(string arg) const { // NOLINT
const char* logger::convert(const string& arg) const {
return arg.c_str();
}