MCPcopy Create free account
hub / github.com/ElementsProject/elements / LegacyParseInt64

Function LegacyParseInt64

src/test/fuzz/string.cpp:66–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66bool LegacyParseInt64(const std::string& str, int64_t* out)
67{
68 if (!LegacyParsePrechecks(str))
69 return false;
70 char* endp = nullptr;
71 errno = 0; // strtoll will not set errno if valid
72 long long int n = strtoll(str.c_str(), &endp, 10);
73 if (out) *out = (int64_t)n;
74 // Note that strtoll returns a *long long int*, so even if strtol doesn't report an over/underflow
75 // we still have to check that the returned value is within the range of an *int64_t*.
76 return endp && *endp == 0 && !errno &&
77 n >= std::numeric_limits<int64_t>::min() &&
78 n <= std::numeric_limits<int64_t>::max();
79}
80
81bool LegacyParseUInt32(const std::string& str, uint32_t* out)
82{

Callers 1

FUZZ_TARGETFunction · 0.85

Calls 1

LegacyParsePrechecksFunction · 0.85

Tested by

no test coverage detected