[compiler-rt] r178158 - tsan: better flag parsing: do not confuse flag that is a part of another flag
Dmitry Vyukov
dvyukov at google.com
Wed Mar 27 10:59:13 PDT 2013
Author: dvyukov
Date: Wed Mar 27 12:59:13 2013
New Revision: 178158
URL: http://llvm.org/viewvc/llvm-project?rev=178158&view=rev
Log:
tsan: better flag parsing: do not confuse flag that is a part of another flag
(e.g. suppressions and print_suppressions)
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc?rev=178158&r1=178157&r2=178158&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc Wed Mar 27 12:59:13 2013
@@ -22,11 +22,20 @@ static bool GetFlagValue(const char *env
const char **value, int *value_length) {
if (env == 0)
return false;
- const char *pos = internal_strstr(env, name);
- const char *end;
- if (pos == 0)
- return false;
+ const char *pos = 0;
+ for (;;) {
+ pos = internal_strstr(env, name);
+ if (pos == 0)
+ return false;
+ if (pos != env && ((pos[-1] >= 'a' && pos[-1] <= 'z') || pos[-1] == '_')) {
+ // Seems to be middle of another flag name or value.
+ env = pos + 1;
+ continue;
+ }
+ break;
+ }
pos += internal_strlen(name);
+ const char *end;
if (pos[0] != '=') {
end = pos;
} else {
More information about the llvm-commits
mailing list