mirror of
https://github.com/Heretek-AI/game-engine.git
synced 2026-11-07 10:55:58 -10:00
illusion: ILLU-FOLLOW snprintf truncation explicit in ApiRegisterSystem
This commit is contained in:
1 parent
1ec8542f1d
commit
dcff5be6dd
1 file changed
+6
-1
@@ -330,7 +330,12 @@ auto ApiRegisterSystem(EngineWorld* world, const char* name,
|
||||
}
|
||||
ManagedSystemEntry entry{};
|
||||
if (name != nullptr) {
|
||||
std::snprintf(entry.name, sizeof(entry.name), "%s", name);
|
||||
// snprintf always NUL-terminates; the return check makes silent
|
||||
// truncation explicit for -Wformat-truncation/MSVC /W4 readers.
|
||||
const int n = std::snprintf(entry.name, sizeof(entry.name), "%s", name);
|
||||
if (n < 0 || static_cast<std::size_t>(n) >= sizeof(entry.name)) {
|
||||
entry.name[sizeof(entry.name) - 1] = '\0';
|
||||
}
|
||||
}
|
||||
entry.callback = callback;
|
||||
entry.user_data = user_data;
|
||||
|
||||
Reference in new issue
Block a user