Skip to content

Commit

Permalink
fix: extend the lifetime of c_str
Browse files Browse the repository at this point in the history
  • Loading branch information
nullptr authored Dec 11, 2023
1 parent ed644bb commit 903ce20
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sscma/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ struct ipv4_addr_t {
for (; (++i < s.length()) & (++n < 3);)
if (!std::isdigit(s[i])) break;
if (n) {
r.addr[l++] = static_cast<uint8_t>(std::atoi(s.substr(i - n, n).c_str()));
auto num{s.substr(i - n, n)};
r.addr[l++] = static_cast<uint8_t>(std::atoi(num.c_str()));
if (l > 3) return r;
}
}
Expand Down

0 comments on commit 903ce20

Please sign in to comment.