diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-07-19 20:53:29 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-07-19 20:53:29 +0200 |
commit | 02f0acb3bce05f3af036495aa36049c67ffbdb52 (patch) | |
tree | 995a476928dc30bfb41ccb534b8cbfc04a52ac7a /kernel | |
parent | efd9604dfb92fda05c3efea67b7c32d812717fa8 (diff) | |
download | yosys-02f0acb3bce05f3af036495aa36049c67ffbdb52.tar.gz yosys-02f0acb3bce05f3af036495aa36049c67ffbdb52.tar.bz2 yosys-02f0acb3bce05f3af036495aa36049c67ffbdb52.zip |
Fixed log_id() memory corruption
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/log.cc | 8 | ||||
-rw-r--r-- | kernel/log.h | 7 |
2 files changed, 10 insertions, 5 deletions
diff --git a/kernel/log.cc b/kernel/log.cc index b2c92e4e1..3108bddfe 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -205,3 +205,11 @@ const char *log_signal(const RTLIL::SigSpec &sig, bool autoint) return string_buf.back().c_str(); } +const char *log_id(std::string str) +{ + if (str.size() > 1 && str[0] == '\\' && str[1] != '$') + string_buf.push_back(str.substr(1)); + else + string_buf.push_back(str); + return string_buf.back().c_str(); +} diff --git a/kernel/log.h b/kernel/log.h index 3e280a6f6..2c3597c9a 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -51,13 +51,10 @@ void log_reset_stack(); void log_flush(); const char *log_signal(const RTLIL::SigSpec &sig, bool autoint = true); - -static inline const char *log_id(std::string id) { - return RTLIL::id2cstr(id); -} +const char *log_id(std::string id); template<typename T> static inline const char *log_id(T *obj) { - return RTLIL::id2cstr(obj->name); + return log_id(obj->name); } #define log_abort() log_error("Abort in %s:%d.\n", __FILE__, __LINE__) |