Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d67a4abc authored by Wei Wang's avatar Wei Wang
Browse files

init: fix undefined behavior in ExecuteCommand

ExecuteCommand may change command_ vector which leads undefined behavior
This bug is found when adding logs in ExecuteCommand printing our Command class fields

Bug: 32838381
Test: on emulator
Change-Id: I96468bd2192ca80013871a3a6ac4132149363fff
parent 8b1d526a
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -105,7 +105,10 @@ std::size_t Action::NumCommands() const {
}

void Action::ExecuteOneCommand(std::size_t command) const {
    ExecuteCommand(commands_[command]);
    // We need a copy here since some Command execution may result in
    // changing commands_ vector by importing .rc files through parser
    Command cmd = commands_[command];
    ExecuteCommand(cmd);
}

void Action::ExecuteAllCommands() const {
+3 −3

File changed.

Contains only whitespace changes.