summaryrefslogtreecommitdiff
path: root/init/action.cpp
diff options
context:
space:
mode:
authorWei Wang <wvw@google.com>2016-11-16 12:08:30 -0800
committerWei Wang <wvw@google.com>2016-11-16 15:46:19 -0800
commitd67a4abc647d5ed7235ff7ee1695b31340e63a1c (patch)
treee51e4b59dc3524c13a99236c12f3ed70cc45e1b3 /init/action.cpp
parent8b1d526a72c1e6705b03f4b3267ee02fe84ce765 (diff)
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
Diffstat (limited to 'init/action.cpp')
-rw-r--r--init/action.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/init/action.cpp b/init/action.cpp
index e9b2a0dfe..acbb12e8e 100644
--- a/init/action.cpp
+++ b/init/action.cpp
@@ -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 {