mirror of
https://github.com/esphome/esphome.git
synced 2025-11-14 13:55:45 +00:00
cleanup
This commit is contained in:
@@ -71,10 +71,17 @@ This document provides essential context for AI models interacting with this pro
|
|||||||
this->current_option_ = nullptr; // Reset to prevent dangling pointer
|
this->current_option_ = nullptr; // Reset to prevent dangling pointer
|
||||||
}
|
}
|
||||||
void set_selected_option(const std::string *option) {
|
void set_selected_option(const std::string *option) {
|
||||||
// Validate that option points to an entry in options_
|
// Validate that option points to an entry in options_ by checking address range
|
||||||
if (std::find(this->options_.begin(), this->options_.end(), *option) != this->options_.end()) {
|
if (option == nullptr) {
|
||||||
this->current_option_ = option;
|
return;
|
||||||
}
|
}
|
||||||
|
for (const auto &opt : this->options_) {
|
||||||
|
if (&opt == option) {
|
||||||
|
this->current_option_ = option;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Invalid pointer - doesn't point to an element in options_
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> options_;
|
std::vector<std::string> options_;
|
||||||
|
|||||||
Reference in New Issue
Block a user