From b351086bc4ea965c9a2bed4ccf8c77ac33ef05ce Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 30 Mar 2026 15:49:31 -0700 Subject: [PATCH] utils: Fix integer underflow in generic vector ostream operator --- libs/utils/include/utils/ostream.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/utils/include/utils/ostream.h b/libs/utils/include/utils/ostream.h index de61c70c9f..d3aba2e436 100644 --- a/libs/utils/include/utils/ostream.h +++ b/libs/utils/include/utils/ostream.h @@ -130,10 +130,13 @@ private: template class VECTOR, typename T> inline ostream& operator<<(ostream& stream, const VECTOR& v) { stream << "< "; - for (size_t i = 0; i < v.size() - 1; i++) { - stream << v[i] << ", "; + if (v.size() > 0) { + for (size_t i = 0; i < v.size() - 1; i++) { + stream << v[i] << ", "; + } + stream << v[v.size() - 1]; } - stream << v[v.size() - 1] << " >"; + stream << " >"; return stream; }