diff --git a/include/cubescript/cubescript.hh b/include/cubescript/cubescript.hh index 48c884f..cba31c7 100644 --- a/include/cubescript/cubescript.hh +++ b/include/cubescript/cubescript.hh @@ -569,7 +569,7 @@ private: bool p_gap; }; -struct cs_error { +struct LIBCUBESCRIPT_EXPORT cs_error { friend struct cs_state; cs_error() = delete; diff --git a/src/cs_vm.cc b/src/cs_vm.cc index 16178e3..4b7200f 100644 --- a/src/cs_vm.cc +++ b/src/cs_vm.cc @@ -131,8 +131,7 @@ std::string_view cs_error::save_msg( ); } if (sz <= 0) { - strncpy(cs.p_errbuf, "format error", sizeof(cs.p_errbuf)); - sz = strlen(cs.p_errbuf); + throw cs_internal_error{"format error"}; } return std::string_view{cs.p_errbuf, std::size_t(sz)}; } diff --git a/src/lib_str.cc b/src/lib_str.cc index 9072a9b..1f6aadb 100644 --- a/src/lib_str.cc +++ b/src/lib_str.cc @@ -150,7 +150,7 @@ void cs_init_lib_string(cs_state &cs) { return; } /* should pretty much be unreachable */ - throw cs_error{ccs, "format error"}; + throw cs_internal_error{"format error"}; }); cs.new_command("substr", "siiN", [](auto &, auto args, auto &res) {