fix issues

- fix lifetime issue about python c callback function
- fix type hint in PyBMap
- fix formatter clamp issue in CKContext
This commit is contained in:
2023-12-03 18:15:05 +08:00
parent a70e32a306
commit b8b2368ef5
4 changed files with 8 additions and 8 deletions

View File

@ -264,7 +264,8 @@ namespace LibCmo::CK2 {
XContainer::XString result;
int count = std::vsnprintf(nullptr, 0, fmt, argptr);
result.resize(count);
int write_result = std::vsnprintf(result.data(), count, fmt, argptr);
// count + 1 for NUL terminator. but we don't need allocate space for it (resize with count). let it write into the reserved tail of std::string.
int write_result = std::vsnprintf(result.data(), count + 1, fmt, argptr);
if (write_result < 0 || write_result > count) return;