Fix stack overruns

This commit is contained in:
Justin C. Miller
2019-04-16 23:39:52 -07:00
parent 6302e8b73a
commit 910b5116f4
5 changed files with 22 additions and 20 deletions

View File

@@ -110,7 +110,7 @@ void fatal(area_t area, const char *fmt, ...);
} // namespace log
namespace logs {
#define LOG(name, lvl) extern log::area_t name;
#define LOG(name, lvl) extern const log::area_t name;
#include "log_areas.inc"
#undef LOG
} // namespace logs

View File

@@ -29,7 +29,7 @@ public:
/// \returns An allocated element
inline item_type * pop()
{
if (this->empty()) allocate();
if (this->empty()) this->allocate();
kassert(!this->empty(), "Slab allocator is empty after allocate()");
item_type *item = this->pop_front();
kutil::memset(item, 0, sizeof(item_type));

View File

@@ -7,7 +7,7 @@
namespace kutil {
namespace logs {
#define LOG(name, lvl) \
log::area_t name = #name ## _h; \
const log::area_t name = #name ## _h; \
const char * name ## _name = #name;
#include "log_areas.inc"
#undef LOG
@@ -19,7 +19,7 @@ using kutil::memset;
using kutil::memcpy;
logger *logger::s_log = nullptr;
const char *logger::s_level_names[] = {"", "debug", " info", " warn", "error", "fatal"};
const char *logger::s_level_names[] = {"", "debug", "info", "warn", "error", "fatal"};
logger::logger() :
m_buffer(nullptr, 0),