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:
parent
d665634484
commit
a45b5d0424
2 changed files with 4 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue