Skip to content

Commit d13942a

Browse files
authored
fix: potential memory leaks (#248)
* fix: potential memory leaks Fixes some potential memory leaks that were raised by static code analyzer. Signed-off-by: Chandio, Bibrak Qamar <[email protected]>
1 parent 16fffbb commit d13942a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

source/layers/validation/checkers/events_checker/zel_events_checker.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,10 @@ void eventsChecker::ZEeventsChecker::checkForDeadlock(
559559
// Form the dependency in the DAG
560560
for (uint32_t i = 0; i < numWaitEvents; i++) {
561561
auto it = eventToDagID.find(phWaitEvents[i]);
562-
562+
if (it == eventToDagID.end()) {
563+
std::cerr << "Warning: phWaitEvents {" << phWaitEvents[i] << "} might be an invalid event in call to " << zeCallDisc << std::endl;
564+
return;
565+
}
563566
uint32_t dagID = it->second;
564567
if (dagID == invalidDagID) {
565568
// Create a new node in the DAG for this wait event. That action will be created some time in the future.

third_party/xla/ordered_set.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,16 @@ class OrderedSet {
5656
// set.
5757
void Erase(T value) {
5858
auto it = value_to_index_.find(value);
59-
assert(it != value_to_index_.end());
59+
if (it == value_to_index_.end()) {
60+
std::cerr << "Value not found in OrderedSet" << std::endl;
61+
exit(0);
62+
}
6063

64+
auto index = it->second;
6165
// Since we don't want to move values around in `value_sequence_` we swap
6266
// the value in the last position and with value to be deleted and then
6367
// pop_back.
64-
value_to_index_[value_sequence_.back()] = it->second;
68+
value_to_index_[value_sequence_.back()] = index;
6569
std::swap(value_sequence_[it->second], value_sequence_.back());
6670
value_sequence_.pop_back();
6771
value_to_index_.erase(it);

0 commit comments

Comments
 (0)