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 authored Nov 21, 2022
1 parent 61ef3ad commit 2d4654a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions include/LightGBM/utils/log.h
Original file line number Diff line number Diff line change
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 2d4654a

Please sign in to comment.