Prevent quiche::PrintElements from crashing when the given container is empty.
PiperOrigin-RevId: 396943487
diff --git a/common/print_elements.h b/common/print_elements.h
index f241a4b..7a0997f 100644
--- a/common/print_elements.h
+++ b/common/print_elements.h
@@ -20,11 +20,13 @@
std::stringstream debug_string;
debug_string << "{";
auto it = container.cbegin();
- debug_string << *it;
- ++it;
- while (it != container.cend()) {
- debug_string << ", " << *it;
+ if (it != container.cend()) {
+ debug_string << *it;
++it;
+ while (it != container.cend()) {
+ debug_string << ", " << *it;
+ ++it;
+ }
}
debug_string << "}";
return debug_string.str();