Prevent incomplete configuration of TrafficGen class from causing
segmentation faults. If an 'INIT' line is not present in the
configuration file then the currState variable will remain
uninitialized which may result in a crash.
name(), configFile);
}
+ bool init_state_set = false;
+
// read line by line and determine the action based on the first
// keyword
string keyword;
// set the initial state as the active state
is >> currState;
+ init_state_set = true;
+
DPRINTF(TrafficGen, "Initial state: %d\n", currState);
}
}
}
+ if (!init_state_set)
+ fatal("%s: initial state not specified (add 'INIT <id>' line "
+ "to the config file)\n", name());
+
// resize and populate state transition matrix
transitionMatrix.resize(states.size());
for (size_t i = 0; i < states.size(); i++) {