Skip to content

Commit

Permalink
Allow to call Hunspell constructor with null/empty paths (#757)
Browse files Browse the repository at this point in the history
It could be used as an object for custom dictionary with words added via application interface.
Currently hunspell throws an exception with nullptr paths and prints a error to stderr when a path is empty.
  • Loading branch information
ilya-fedin committed Jun 30, 2022
1 parent 31e6d63 commit 6d8505b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/hunspell/filemgr.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ int FileMgr::fail(const char* err, const char* par) {
FileMgr::FileMgr(const char* file, const char* key) : hin(NULL), linenum(0) {
in[0] = '\0';

if (!file || !strlen(file))
return;
myopen(fin, file, std::ios_base::in);
if (!fin.is_open()) {
// check hzipped file
Expand All @@ -103,7 +105,7 @@ bool FileMgr::getline(std::string& dest) {
++linenum;
if (fin.is_open()) {
ret = static_cast<bool>(std::getline(fin, dest));
} else if (hin->is_open()) {
} else if (hin && hin->is_open()) {
ret = hin->getline(dest);
}
if (!ret) {
Expand Down

0 comments on commit 6d8505b

Please sign in to comment.