mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-22 14:50:54 +00:00
more ASAN fixes
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
This commit is contained in:
@@ -54,12 +54,8 @@ struct LocalValuesHolder
|
||||
}
|
||||
};
|
||||
|
||||
inline LocalValuesHolder&
|
||||
getLocalValuesHolder()
|
||||
{
|
||||
thread_local LocalValuesHolder holder;
|
||||
return holder;
|
||||
}
|
||||
LocalValuesHolder&
|
||||
getLocalValuesHolder();
|
||||
|
||||
inline LocalValues*&
|
||||
getLocalValuesPtr()
|
||||
|
||||
@@ -139,6 +139,13 @@ public:
|
||||
template <typename T>
|
||||
ScopedStream(Stream const& stream, T const& t);
|
||||
|
||||
/** Overload for const char* to ensure immediate copy.
|
||||
This prevents stack-use-after-scope issues when the source
|
||||
pointer becomes invalid before the stream buffer operations
|
||||
complete (e.g., during buffer reallocation).
|
||||
*/
|
||||
ScopedStream(Stream const& stream, char const* t);
|
||||
|
||||
ScopedStream(Stream const& stream, std::ostream& manip(std::ostream&));
|
||||
|
||||
ScopedStream&
|
||||
@@ -159,6 +166,18 @@ public:
|
||||
std::ostream&
|
||||
operator<<(T const& t) const;
|
||||
|
||||
/** Overload for const char* to ensure immediate copy.
|
||||
This prevents stack-use-after-scope issues when the source
|
||||
pointer becomes invalid before the stream buffer operations
|
||||
complete (e.g., during buffer reallocation).
|
||||
*/
|
||||
std::ostream&
|
||||
operator<<(char const* t) const
|
||||
{
|
||||
m_ostream << std::string(t);
|
||||
return m_ostream;
|
||||
}
|
||||
|
||||
private:
|
||||
Sink& m_sink;
|
||||
Severity const m_level;
|
||||
@@ -239,6 +258,17 @@ public:
|
||||
template <typename T>
|
||||
ScopedStream
|
||||
operator<<(T const& t) const;
|
||||
|
||||
/** Overload for const char* to ensure immediate copy.
|
||||
This prevents stack-use-after-scope issues when the source
|
||||
pointer becomes invalid before the stream buffer operations
|
||||
complete (e.g., during buffer reallocation).
|
||||
*/
|
||||
ScopedStream
|
||||
operator<<(char const* t) const
|
||||
{
|
||||
return ScopedStream(*this, t);
|
||||
}
|
||||
/** @} */
|
||||
|
||||
private:
|
||||
|
||||
14
src/libxrpl/basics/LocalValue.cpp
Normal file
14
src/libxrpl/basics/LocalValue.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <xrpl/basics/LocalValue.h>
|
||||
|
||||
namespace xrpl {
|
||||
namespace detail {
|
||||
|
||||
LocalValuesHolder&
|
||||
getLocalValuesHolder()
|
||||
{
|
||||
thread_local LocalValuesHolder holder;
|
||||
return holder;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace xrpl
|
||||
@@ -118,6 +118,14 @@ Journal::ScopedStream::ScopedStream(Stream const& stream, std::ostream& manip(st
|
||||
m_ostream << manip;
|
||||
}
|
||||
|
||||
Journal::ScopedStream::ScopedStream(Stream const& stream, char const* t) : ScopedStream(stream.sink(), stream.level())
|
||||
{
|
||||
// Convert to std::string immediately to ensure the data is copied.
|
||||
// This prevents stack-use-after-scope issues when the source pointer
|
||||
// becomes invalid before stream buffer operations(like reallocation) complete.
|
||||
m_ostream << std::string(t);
|
||||
}
|
||||
|
||||
Journal::ScopedStream::~ScopedStream()
|
||||
{
|
||||
std::string const& s(m_ostream.str());
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
static uint256 const&
|
||||
static uint256 const
|
||||
depthMask(unsigned int depth)
|
||||
{
|
||||
enum { mask_size = 65 };
|
||||
|
||||
Reference in New Issue
Block a user