Sanity-check field trial string at initialization.

It's easy to make small errors when building field trial strings, and
those errors can cause all sorts of weird problems. This CL checks if
the FT string has an odd number of delimiters, duplicate
names or any trailing chars.

If so we'll log a error message. On debug builds we'll also crash.

Bug: webrtc:10729
Change-Id: Iebf7155d9b117a02d1e9cfe7f64408e11df2aec5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/140866
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28234}
This commit is contained in:
Jonas Olsson
2019-06-11 14:29:40 +02:00
committed by Commit Bot
parent e8e4dc4c8b
commit 5b2eda4895
15 changed files with 127 additions and 84 deletions

View File

@ -10,6 +10,7 @@
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <map>
#include <memory>
@ -275,7 +276,6 @@ int main(int argc, char* argv[]) {
return 0;
}
webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials);
// InitFieldTrialsFromString stores the char*, so the char array must outlive
// the application.
webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);