Update unguarded stoi handling
Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
This commit is contained in:
parent
f8bf0fd0e2
commit
2a5592122d
|
|
@ -86,7 +86,9 @@ parseBusName(std::string_view name,
|
||||||
if (brkt_index != std::string_view::npos) {
|
if (brkt_index != std::string_view::npos) {
|
||||||
char brkt_left_ch = brkts_left[brkt_index];
|
char brkt_left_ch = brkts_left[brkt_index];
|
||||||
size_t left = name.rfind(brkt_left_ch);
|
size_t left = name.rfind(brkt_left_ch);
|
||||||
if (left != std::string_view::npos) {
|
if (left != std::string_view::npos
|
||||||
|
&& left + 1 < len
|
||||||
|
&& isdigit(name[left + 1])) {
|
||||||
is_bus = true;
|
is_bus = true;
|
||||||
bus_name.append(name.data(), left);
|
bus_name.append(name.data(), left);
|
||||||
// Simple bus subscript.
|
// Simple bus subscript.
|
||||||
|
|
@ -140,19 +142,21 @@ parseBusName(std::string_view name,
|
||||||
if (brkt_index != std::string_view::npos) {
|
if (brkt_index != std::string_view::npos) {
|
||||||
char brkt_left_ch = brkts_left[brkt_index];
|
char brkt_left_ch = brkts_left[brkt_index];
|
||||||
size_t left = name.rfind(brkt_left_ch);
|
size_t left = name.rfind(brkt_left_ch);
|
||||||
if (left != std::string_view::npos) {
|
if (left != std::string_view::npos
|
||||||
|
&& left + 1 < len
|
||||||
|
&& (isdigit(name[left + 1]) || name[left + 1] == '*')) {
|
||||||
is_bus = true;
|
is_bus = true;
|
||||||
bus_name.append(name.data(), left);
|
bus_name.append(name.data(), left);
|
||||||
// Check for bus range.
|
if (name[left + 1] == '*')
|
||||||
size_t range = name.find(':', left);
|
subscript_wild = true;
|
||||||
if (range != std::string_view::npos) {
|
|
||||||
is_range = true;
|
|
||||||
from = std::stoi(std::string(name.substr(left + 1)));
|
|
||||||
to = std::stoi(std::string(name.substr(range + 1)));
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
if (left + 1 < len && name[left + 1] == '*')
|
// Check for bus range.
|
||||||
subscript_wild = true;
|
size_t range = name.find(':', left);
|
||||||
|
if (range != std::string_view::npos) {
|
||||||
|
is_range = true;
|
||||||
|
from = std::stoi(std::string(name.substr(left + 1)));
|
||||||
|
to = std::stoi(std::string(name.substr(range + 1)));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
from = to = std::stoi(std::string(name.substr(left + 1)));
|
from = to = std::stoi(std::string(name.substr(left + 1)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue