Skip to content

Commit 77ed999

Browse files
author
nitrocaster
committed
Add IWriter::VPrintf function.
1 parent 91f03a8 commit 77ed999

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/xrCore/FS.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,19 +321,19 @@ void IWriter::w_sdir(const Fvector& D)
321321
w_dir(C);
322322
w_float(mag);
323323
}
324+
// XXX: reimplement to prevent buffer overflows
324325
void IWriter::w_printf(const char* format, ...)
325326
{
326-
va_list mark;
327-
char buf[1024];
328-
329-
va_start(mark, format);
330-
#ifndef _EDITOR
331-
vsprintf_s(buf, format, mark);
332-
#else
333-
vsprintf(buf, format, mark);
334-
#endif
335-
va_end(mark);
327+
va_list args;
328+
va_start(args, format);
329+
VPrintf(format, args);
330+
va_end(args);
331+
}
336332

333+
void IWriter::VPrintf(const char *format, va_list args)
334+
{
335+
char buf[1024];
336+
std::vsnprintf(buf, sizeof(buf), format, args);
337337
w(buf, xr_strlen(buf));
338338
}
339339

src/xrCore/FS.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class XRCORE_API IWriter
8585
IC void w_dir(const Fvector& D) { w_u16(pvCompress(D)); }
8686
void w_sdir(const Fvector& D);
8787
void __cdecl w_printf(const char* format, ...);
88+
void VPrintf(const char *format, va_list args);
8889

8990
// generalized chunking
9091
u32 align();

0 commit comments

Comments
 (0)