Skip to content

Commit

Permalink
prefer 'vsnprintf' to 'vsprintf' (#5561)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Dec 6, 2022
1 parent a0a617d commit 37d749f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions include/LightGBM/utils/log.h
Expand Up @@ -109,12 +109,13 @@ class Log {
}
static void Fatal(const char *format, ...) {
va_list val;
char str_buf[1024];
const size_t kBufSize = 1024;
char str_buf[kBufSize];
va_start(val, format);
#ifdef _MSC_VER
vsprintf_s(str_buf, format, val);
vsnprintf_s(str_buf, kBufSize, format, val);
#else
vsprintf(str_buf, format, val);
vsnprintf(str_buf, kBufSize, format, val);
#endif
va_end(val);

Expand Down

0 comments on commit 37d749f

Please sign in to comment.