Skip to content

Commit

Permalink
Catch bad alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
uhlin committed Jan 20, 2024
1 parent 916bf73 commit b483f7e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ spell_get_suggs(CSTRING mbs, const wchar_t *wcs)
try {
ptr = new suggestion(list[i]);
suggs->push_back(ptr);
} catch (const std::bad_alloc &e) {
err_exit(ENOMEM, "%s: fatal: %s", __func__, e.what());
} catch (const std::runtime_error &e) {
delete ptr;
debug("%s: %s", __func__, e.what());
Expand Down

0 comments on commit b483f7e

Please sign in to comment.