Skip to content

Commit

Permalink
fix XRPLF#4569: clang warning about deprecated sprintf usage.
Browse files Browse the repository at this point in the history
Instead of sprintf use the suggested snprintf function
  • Loading branch information
ckeshava committed Jun 12, 2023
1 parent c9a586c commit 85f1ba7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/ripple/basics/impl/contract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <ripple/basics/Log.h>
#include <ripple/basics/contract.h>
#include <cstdlib>
#include <exception>
#include <iostream>

namespace ripple {
Expand Down
11 changes: 9 additions & 2 deletions src/ripple/json/impl/json_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include <algorithm>
#include <cctype>
#include <cstdint>
#include <istream>
#include <string>

Expand Down Expand Up @@ -925,7 +924,15 @@ Reader::getLocationLineAndColumn(Location location) const
int line, column;
getLocationLineAndColumn(location, line, column);
char buffer[18 + 16 + 16 + 1];
sprintf(buffer, "Line %d, Column %d", line, column);
int generatedStrLen =
snprintf(buffer, 51, "Line %d, Column %d", line, column);

if (generatedStrLen < 0)
{
ripple::LogicError(
"json_reader: Exception in "
"getLocationLineAndColumn - Could not write into buffer\n");
}
return buffer;
}

Expand Down

0 comments on commit 85f1ba7

Please sign in to comment.