Commit fea2a562 authored by Chen Bill's avatar Chen Bill

Check empty file path in LoadCurrentDeck

parent 961517bb
...@@ -293,6 +293,9 @@ bool DeckManager::LoadCurrentDeck(std::istringstream& deckStream, bool is_packli ...@@ -293,6 +293,9 @@ bool DeckManager::LoadCurrentDeck(std::istringstream& deckStream, bool is_packli
} }
bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) { bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) {
current_deck.clear(); current_deck.clear();
if (!file[0])
return false;
char deckBuffer[MAX_YDK_SIZE]{};
auto reader = OpenDeckReader(file); auto reader = OpenDeckReader(file);
if(!reader) { if(!reader) {
wchar_t localfile[256]; wchar_t localfile[256];
...@@ -319,10 +322,6 @@ bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) { ...@@ -319,10 +322,6 @@ bool DeckManager::LoadCurrentDeck(const wchar_t* file, bool is_packlist) {
bool DeckManager::LoadCurrentDeck(int category_index, const wchar_t* category_name, const wchar_t* deckname) { bool DeckManager::LoadCurrentDeck(int category_index, const wchar_t* category_name, const wchar_t* deckname) {
wchar_t filepath[256]; wchar_t filepath[256];
GetDeckFile(filepath, category_index, category_name, deckname); GetDeckFile(filepath, category_index, category_name, deckname);
if (!filepath[0]) {
current_deck.clear();
return false;
}
bool is_packlist = (category_index == DECK_CATEGORY_PACK); bool is_packlist = (category_index == DECK_CATEGORY_PACK);
if(!LoadCurrentDeck(filepath, is_packlist)) if(!LoadCurrentDeck(filepath, is_packlist))
return false; return false;
......
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