diff --git a/include/rocksdb/slice.h b/include/rocksdb/slice.h index 76ecce684..e6d8dfc60 100644 --- a/include/rocksdb/slice.h +++ b/include/rocksdb/slice.h @@ -43,7 +43,9 @@ class Slice { // Create a slice that refers to s[0,strlen(s)-1] /* implicit */ - Slice(const char* s) : data_(s), size_(strlen(s)) { } + Slice(const char* s) : data_(s) { + size_ = (s == nullptr) ? 0 : strlen(s); + } // Create a single slice from SliceParts using buf as storage. // buf must exist as long as the returned Slice exists.