Fix UBSAN report

/home/anoyes/workspace/foundationdb/fdbclient/SnapshotCache.h:44:10: runtime error: null pointer passed as argument 2, which is declared to never be null
This commit is contained in:
Andrew Noyes 2019-12-03 22:01:04 -08:00
parent 560c1da805
commit cc170fe8d8
1 changed files with 3 additions and 1 deletions

View File

@ -41,7 +41,9 @@ struct ExtStringRef {
StringRef toArenaOrRef( Arena& a ) { StringRef toArenaOrRef( Arena& a ) {
if (extra_zero_bytes) { if (extra_zero_bytes) {
StringRef dest = StringRef( new(a) uint8_t[ size() ], size() ); StringRef dest = StringRef( new(a) uint8_t[ size() ], size() );
memcpy( mutateString(dest), base.begin(), base.size() ); if (base.size()) {
memcpy(mutateString(dest), base.begin(), base.size());
}
memset( mutateString(dest)+base.size(), 0, extra_zero_bytes ); memset( mutateString(dest)+base.size(), 0, extra_zero_bytes );
return dest; return dest;
} else } else