logging: don't clamp the log level to DFATAL in debug builds
[folly.git] / folly / experimental / StringKeyedCommon.h
index c79d7b7c7078508103904a4a91b27a8c10bb27bc..ae15dd3d91ec0c64dac76e4c01647b70d63ef47c 100644 (file)
@@ -19,6 +19,7 @@
 #pragma once
 
 #include <memory>
+
 #include <folly/Range.h>
 
 namespace folly {
@@ -28,7 +29,10 @@ StringPiece stringPieceDup(StringPiece piece, const Alloc& alloc) {
   auto size = piece.size();
   auto keyDup = typename Alloc::template rebind<char>::other(alloc)
     .allocate(size);
-  memcpy(keyDup, piece.data(), size * sizeof(StringPiece::value_type));
+  if (size) {
+    memcpy(
+        keyDup, piece.data(), size * sizeof(typename StringPiece::value_type));
+  }
   return StringPiece(keyDup, size);
 }
 
@@ -38,4 +42,4 @@ void stringPieceDel(StringPiece piece, const Alloc& alloc) {
     .deallocate(const_cast<char*>(piece.data()), piece.size());
 }
 
-} // folly
+} // namespace folly