diff --git a/src/Text.hh b/src/Text.hh index 695d7ddf..f621db10 100644 --- a/src/Text.hh +++ b/src/Text.hh @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -246,6 +247,9 @@ struct parray { } parray& operator=(const ItemT* s) { + if (!s) { + throw std::logic_error("attempted to assign nullptr to parray"); + } for (size_t x = 0; x < Count; x++) { this->items[x] = s[x]; } @@ -293,10 +297,16 @@ struct ptext : parray { template ptext(const OtherCharT* s) { + if (!s) { + throw std::logic_error("attempted to assign nullptr to ptext"); + } this->operator=(s); } template ptext(const OtherCharT* s, size_t count) { + if (!s) { + throw std::logic_error("attempted to assign nullptr to ptext"); + } this->assign(s, count); } template @@ -323,12 +333,18 @@ struct ptext : parray { template ptext& operator=(const OtherCharT* s) { + if (!s) { + throw std::logic_error("attempted to assign nullptr to ptext"); + } size_t chars_written = text_strncpy_t(this->items, Count, s, Count); this->clear_after(chars_written); return *this; } template ptext& assign(const OtherCharT* s, size_t s_count) { + if (!s) { + throw std::logic_error("attempted to assign nullptr to ptext"); + } size_t chars_written = text_strncpy_t(this->items, Count, s, s_count); this->clear_after(chars_written); return *this; @@ -348,6 +364,9 @@ struct ptext : parray { template bool operator==(const OtherCharT* s) const { + if (!s) { + throw std::logic_error("attempted to compare ptext to nullptr"); + } return text_strneq_t(this->items, s, Count); } template @@ -360,6 +379,9 @@ struct ptext : parray { } template bool operator!=(const OtherCharT* s) const { + if (!s) { + throw std::logic_error("attempted to compare ptext to nullptr"); + } return !this->operator==(s); } template @@ -373,6 +395,9 @@ struct ptext : parray { template bool eq_n(const OtherCharT* s, size_t count) const { + if (!s) { + throw std::logic_error("attempted to compare ptext to nullptr"); + } return text_strneq_t(this->items, s, count); } template