Use vector instead of VLA to avoid uninitialized values

I502b34f23d61a7346d79ff0dc378add8461d2d27 added a continue before
skip[i] was set, which left it uninitialized and caused
non-deterministic output of incident-section-gen incidentd and a
non-deterministic incidentd binary.  Use a vector instead of a
variable length array for skip so that it is always initialized.

Test: valgrind incident-section-gen incidentd
Change-Id: Iac9778dc8bbf4ec5540e5e2ffdaa8e2dd852d6cc
This commit is contained in:
Colin Cross
2018-12-19 22:55:15 -08:00
parent 90c5bfe077
commit b9e195546e

View File

@@ -453,7 +453,7 @@ static bool generateSectionListCpp(Descriptor const* descriptor) {
map<string, bool> variableNames;
set<string> parents;
vector<const FieldDescriptor*> fieldsInOrder = sortFields(descriptor);
bool skip[fieldsInOrder.size()];
vector<bool> skip(fieldsInOrder.size());
const Destination incidentDest = getPrivacyFlags(descriptor).dest();
for (size_t i=0; i<fieldsInOrder.size(); i++) {