Skip to content

Commit a0dc63d

Browse files
committed
mon/MonMap.h: fix potential segfault, add assert()
Fix for: CID 1297860 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS) 1. Condition this->mon_addr.count(n), taking true branch 2. negative_return_fn: Function this->get_rank(n) returns a negative number. [show details] 3. var_assign: Assigning: signed variable m = get_rank. 4. negative_returns: m is passed to a parameter that cannot be negative. Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
1 parent 0292f96 commit a0dc63d

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/mon/MonMap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class MonMap {
159159
entity_inst_t get_inst(const string& n) {
160160
assert(mon_addr.count(n));
161161
int m = get_rank(n);
162+
assert(m >= 0); // vector can't take negative indicies
162163
entity_inst_t i;
163164
i.addr = rank_addr[m];
164165
i.name = entity_name_t::MON(m);

0 commit comments

Comments
 (0)