]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Fix Issue #3771: Slice ctor checks for nullptr and creates empty string
authorJacquin Mininger <jacquin.mininger@gmail.com>
Tue, 22 May 2018 20:34:26 +0000 (13:34 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 22 May 2018 20:41:56 +0000 (13:41 -0700)
Summary:
Fix Issue #3771   : Check for nullptr in Slice constructor
Slice ctor checks for nullptr and creates empty string if the string does not exist
Closes https://github.com/facebook/rocksdb/pull/3887

Differential Revision: D8098852

Pulled By: ajkr

fbshipit-source-id: 04471077defa9776ce7b8c389a61312ce31002fb

include/rocksdb/slice.h

index 76ecce68426accdb7561570d6819db28bbe34df0..e6d8dfc601283ef0b49204d214baf903b410460e 100644 (file)
@@ -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.