Skip to content

Commit 0b73b29

Browse files
committed
rt: Don't overshoot the end of the logging spec during parsing
1 parent 9e9d576 commit 0b73b29

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: src/rt/rust_log.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,22 @@ size_t parse_logging_spec(char* spec, log_directive* dirs) {
154154
cur = *spec;
155155
if (cur == ',' || cur == '=' || cur == '\0') {
156156
if (start == spec) {spec++; break;}
157-
*spec = '\0';
158-
spec++;
157+
if (*spec != '\0') {
158+
*spec = '\0';
159+
spec++;
160+
}
159161
size_t level = max_log_level;
160-
if (cur == '=') {
162+
if (cur == '=' && *spec != '\0') {
161163
level = *spec - '0';
162164
if (level > max_log_level) level = max_log_level;
163165
if (*spec) ++spec;
164166
}
165167
dirs[dir].name = start;
166168
dirs[dir++].level = level;
167169
break;
170+
} else {
171+
spec++;
168172
}
169-
spec++;
170173
}
171174
}
172175
return dir;

0 commit comments

Comments
 (0)