From f609e8a7856cbb4d530fce601d17f47af592a9aa Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 9 Aug 2019 03:00:32 +0300 Subject: [PATCH] Slightly more safe parsing of NamesAndTypesList --- dbms/src/Core/NamesAndTypes.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dbms/src/Core/NamesAndTypes.cpp b/dbms/src/Core/NamesAndTypes.cpp index 09985d97463..15c2be689bf 100644 --- a/dbms/src/Core/NamesAndTypes.cpp +++ b/dbms/src/Core/NamesAndTypes.cpp @@ -26,16 +26,20 @@ void NamesAndTypesList::readText(ReadBuffer & buf) size_t count; DB::readText(count, buf); assertString(" columns:\n", buf); - resize(count); - for (NameAndTypePair & it : *this) + + String column_name; + String type_name; + for (size_t i = 0; i < count; ++i) { - readBackQuotedStringWithSQLStyle(it.name, buf); + readBackQuotedStringWithSQLStyle(column_name, buf); assertChar(' ', buf); - String type_name; readString(type_name, buf); - it.type = data_type_factory.get(type_name); assertChar('\n', buf); + + emplace_back(column_name, data_type_factory.get(type_name)); } + + assertEOF(buf); } void NamesAndTypesList::writeText(WriteBuffer & buf) const