about summary refs log tree commit diff
path: root/absl/strings/internal
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-05-09T20·57-0700
committerJohn Olson <jolson@google.com>2018-05-09T21·08-0400
commitcd95e71df6eaf8f2a282b1da556c2cf1c9b09207 (patch)
tree19966a5ce40419a43bca17d15fe93cfda96a87c1 /absl/strings/internal
parenta193b3d3b7c3fe2785bff32125a5e1633d3bc0e2 (diff)
- e63f59e34d34d483f89e4e6a7fe80805d1332329 This CL replicates github.com/abseil/abseil-cpp/pull/117 ... by Abseil Team <absl-team@google.com>
  - 8444789eefc1f20c0102041ee52ad841131dcf93 Import of CCTZ from Github. by Abseil Team <absl-team@google.com>
  - 847bf3389edff542cdfcc4fcfb5b1d7466a5d297 Suggest using MakeSpan rather than the explicit mutable r... by Abseil Team <absl-team@google.com>
  - b6f130c12a3b2e8ea14e848df523f3ca8d360d25 ABSL_ARRAYSIZE is now declared and documented more clearl... by Matt Armstrong <marmstrong@google.com>
  - 8243bbcd7398e0cc1fed405b3c7cecc54fe77145 Don't dereference the begin() iterator of an empty string. by Derek Mauro <dmauro@google.com>
  - be817477eb17964a0f4c2a943c8281763ee269b0 Revert rename THREAD_ANNOTATION_ATTRIBUTE__ by Abseil Team <absl-team@google.com>
  - 940d4657f63acd7ff61d986558b0a38fa545a1fe Don't create '".text"' section when '.text' was intended. by Abseil Team <absl-team@google.com>
  - f6680d634b66537acec18121fbdca7c9083877b1 Rename THREAD_ANNOTATION_ATTRIBUTE__ by Abseil Team <absl-team@google.com>

GitOrigin-RevId: e63f59e34d34d483f89e4e6a7fe80805d1332329
Change-Id: If6f2286d6cbfd7b822e83c6cc28fa3e752bb41a4
Diffstat (limited to 'absl/strings/internal')
-rw-r--r--absl/strings/internal/str_join_internal.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/absl/strings/internal/str_join_internal.h b/absl/strings/internal/str_join_internal.h
index c5fdc287cbab..a734758c21ee 100644
--- a/absl/strings/internal/str_join_internal.h
+++ b/absl/strings/internal/str_join_internal.h
@@ -234,17 +234,19 @@ std::string JoinAlgorithm(Iterator start, Iterator end, absl::string_view s,
       result_size += it->size();
     }
 
-    STLStringResizeUninitialized(&result, result_size);
-
-    // Joins strings
-    char* result_buf = &*result.begin();
-    memcpy(result_buf, start->data(), start->size());
-    result_buf += start->size();
-    for (Iterator it = start; ++it != end;) {
-      memcpy(result_buf, s.data(), s.size());
-      result_buf += s.size();
-      memcpy(result_buf, it->data(), it->size());
-      result_buf += it->size();
+    if (result_size > 0) {
+      STLStringResizeUninitialized(&result, result_size);
+
+      // Joins strings
+      char* result_buf = &*result.begin();
+      memcpy(result_buf, start->data(), start->size());
+      result_buf += start->size();
+      for (Iterator it = start; ++it != end;) {
+        memcpy(result_buf, s.data(), s.size());
+        result_buf += s.size();
+        memcpy(result_buf, it->data(), it->size());
+        result_buf += it->size();
+      }
     }
   }