C++: replace deprecated vsprintf and sprintf

With future C++ compilers the methods vsprintf and sprintf are declared as deprecated due to security issues.
They are replaced with the secure counterpart of the fmt library

Fixes the compiler warnings -Wdeprecated-declarations
This commit is contained in:
wmayer
2024-04-03 07:29:10 +02:00
committed by wwmayer
parent d8a194a70b
commit 0b08ea3368
4 changed files with 18 additions and 12 deletions

View File

@@ -26,6 +26,7 @@
#include <QMenu>
#endif
#include <fmt/printf.h>
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
@@ -176,8 +177,8 @@ void orthoview::set_data(int r_x, int r_y)
rel_x = r_x;
rel_y = r_y;
char label[15];
sprintf(label, "Ortho_%i_%i", rel_x, rel_y); // label name for view, based on relative position
// label name for view, based on relative position
std::string label = fmt::sprintf("Ortho_%i_%i", rel_x, rel_y);
this_view->Label.setValue(label);
ortho = ((rel_x * rel_y) == 0);

View File

@@ -893,7 +893,7 @@ int System::Sprintf (char* acDst, size_t uiDstSize, const char* acFormat, ...)
#ifdef WM4_USING_VC80
int iNumWritten = vsprintf_s(acDst,uiDstSize,acFormat,acArgs);
#else
int iNumWritten = vsprintf(acDst,acFormat,acArgs);
int iNumWritten = vsnprintf(acDst,uiDstSize,acFormat,acArgs);
#endif
va_end(acArgs);