diff --git a/src/lib/orderman/orderman_utils/orderman_common.h b/src/lib/orderman/orderman_utils/orderman_common.h index 87bfa9006..e8348b918 100644 --- a/src/lib/orderman/orderman_utils/orderman_common.h +++ b/src/lib/orderman/orderman_utils/orderman_common.h @@ -104,6 +104,9 @@ std::pair find_trim_strn(std::array const &in) { while (i > 0 && (in[i - 1] == ' ' || in[i - 1] == 0)) { i--; } + if (i == 0) { + return {nullptr, 0}; + } return {&in[0], i}; } @@ -116,6 +119,9 @@ std::string to_trim_str(T const &t) { template std::string to_trim_strn(T const &t) { auto ts = find_trim_strn(t.value()); + if (ts.second == 0) { + return {}; + } return std::string{ts.first, ts.second}; }