Skip to content

Commit 1f76808

Browse files
committedOct 24, 2015
Fix out of bounds vector write in Logger::addOutput(ILogOutput *out)
Previously, the invocation of Logger::addOutput(ILogOutput *out) led to an out of bounds write of the m_outputs vector, resulting in the m_silenced_levels array being modified. Fortunately, the only caller of that method was android system logging, and only since a few commits ago.
1 parent 7d5c736 commit 1f76808

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

‎src/log.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ LogLevel Logger::stringToLevel(const std::string &name)
172172

173173
void Logger::addOutput(ILogOutput *out)
174174
{
175-
addOutputMaxLevel(out, LL_MAX);
175+
addOutputMaxLevel(out, (LogLevel)(LL_MAX - 1));
176176
}
177177

178178
void Logger::addOutput(ILogOutput *out, LogLevel lev)
@@ -182,6 +182,7 @@ void Logger::addOutput(ILogOutput *out, LogLevel lev)
182182

183183
void Logger::addOutputMaxLevel(ILogOutput *out, LogLevel lev)
184184
{
185+
assert(lev < LL_MAX);
185186
for (size_t i = 0; i <= lev; i++)
186187
m_outputs[i].push_back(out);
187188
}

0 commit comments

Comments
 (0)
Please sign in to comment.