mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-29 11:01:23 +00:00
util/logging: Don't reuse vargs (#632)
As vargs may be modified by some functions, we should not reuse it and instead create a copy of it. This fixes a segfault on logging calls happening with GCC, and potentially may fix other compilers and platforms as well.
This commit is contained in:
parent
04c7116f5a
commit
3eacc47085
1 changed files with 4 additions and 1 deletions
|
@ -34,11 +34,14 @@ void streamfx::util::logging::log(level lvl, const char* format, ...)
|
|||
va_list vargs;
|
||||
va_start(vargs, format);
|
||||
|
||||
va_list vargs_copy;
|
||||
va_copy(vargs_copy, vargs);
|
||||
int32_t ret = vsnprintf(buffer.data(), buffer.size(), format, vargs);
|
||||
buffer.resize(ret + 1);
|
||||
ret = vsnprintf(buffer.data(), buffer.size(), format, vargs);
|
||||
ret = vsnprintf(buffer.data(), buffer.size(), format, vargs_copy);
|
||||
|
||||
va_end(vargs);
|
||||
va_end(vargs_copy);
|
||||
|
||||
blog(level_map.at(lvl), "[StreamFX] %s", buffer.data());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue