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
@ -100,7 +100,7 @@ class logger {
|
|||||||
/**
|
/**
|
||||||
* Convert string
|
* Convert string
|
||||||
*/
|
*/
|
||||||
const char* convert(string arg) const; // NOLINT
|
const char* convert(const string& arg) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert thread id
|
* Convert thread id
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
#include "components/logger.hpp"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "components/logger.hpp"
|
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
#include "utils/concurrency.hpp"
|
#include "utils/concurrency.hpp"
|
||||||
@ -12,7 +13,7 @@ POLYBAR_NS
|
|||||||
/**
|
/**
|
||||||
* Convert string
|
* Convert string
|
||||||
*/
|
*/
|
||||||
const char* logger::convert(string arg) const { // NOLINT
|
const char* logger::convert(const string& arg) const {
|
||||||
return arg.c_str();
|
return arg.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user