Commit 53f97ff0 authored by Chen Bill's avatar Chen Bill

wcsncpy capped at N

parent b22ff21a
......@@ -1250,8 +1250,9 @@ void Game::RefreshDeck(const wchar_t* deckpath, const std::function<void(const w
if (!isdir && IsExtension(name, L".ydk")) {
size_t len = std::wcslen(name);
wchar_t deckname[256];
std::wcsncpy(deckname, name, len - 4);
deckname[len - 4] = 0;
size_t count = std::min(len - 4, sizeof deckname / sizeof deckname[0]);
std::wcsncpy(deckname, name, count);
deckname[(sizeof deckname / sizeof deckname[0]) - 1] = 0;
additem(deckname);
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment