mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-25 08:40:05 +08:00
Fix UBSAN report
/home/anoyes/workspace/foundationdb/fdbclient/SnapshotCache.h:36:9: runtime error: null pointer passed as argument 2, which is declared to never be null
This commit is contained in:
parent
e6678573db
commit
c8e8d0c8ab
@ -33,7 +33,9 @@ struct ExtStringRef {
|
||||
|
||||
Standalone<StringRef> toStandaloneStringRef() {
|
||||
auto s = makeString( size() );
|
||||
memcpy( mutateString( s ), base.begin(), base.size() );
|
||||
if (base.size() > 0) {
|
||||
memcpy(mutateString(s), base.begin(), base.size());
|
||||
}
|
||||
memset( mutateString( s ) + base.size(), 0, extra_zero_bytes );
|
||||
return s;
|
||||
};
|
||||
@ -58,7 +60,9 @@ struct ExtStringRef {
|
||||
StringRef toArena( Arena& a ) {
|
||||
if (extra_zero_bytes) {
|
||||
StringRef dest = StringRef( new(a) uint8_t[ size() ], size() );
|
||||
memcpy( mutateString(dest), base.begin(), base.size() );
|
||||
if (base.size() > 0) {
|
||||
memcpy(mutateString(dest), base.begin(), base.size());
|
||||
}
|
||||
memset( mutateString(dest)+base.size(), 0, extra_zero_bytes );
|
||||
return dest;
|
||||
} else
|
||||
|
Loading…
x
Reference in New Issue
Block a user