Merge pull request #3095 from firewave/core_strdup2

removed core_strdup() usage from ti99 cartridge code (nw)
This commit is contained in:
ajrhacker 2018-01-20 18:21:10 -05:00 committed by GitHub
commit 69982b92f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -239,7 +239,7 @@ image_init_result ti99_cartridge_device::call_load()
}
catch (rpk_exception& err)
{
logerror("Failed to load cartridge '%s': %s\n", basename(), err.to_string());
logerror("Failed to load cartridge '%s': %s\n", basename(), err.to_string().c_str());
m_rpk = nullptr;
m_err = IMAGE_ERROR_INVALIDIMAGE;
return image_init_result::FAIL;

View File

@ -119,12 +119,12 @@ private:
rpk_exception(rpk_open_error value): m_err(value), m_detail(nullptr) { }
rpk_exception(rpk_open_error value, const char* detail) : m_err(value), m_detail(detail) { }
const char* to_string()
std::string to_string()
{
// FIXME: this leaks memory - in some cases it returns a new buffer, in other cases it returns a pointer to a static string, so the caller can't know whether it needs to be cleaned up
if (m_detail==nullptr) return error_text[(int)m_err];
std::string errormsg = std::string(error_text[(int)m_err]).append(": ").append(m_detail);
return core_strdup(errormsg.c_str());
std::string errmsg(error_text[(int)m_err]);
if (m_detail==nullptr)
return errmsg;
return errmsg.append(": ").append(m_detail);
}
private: