diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-02-09 17:10:08 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-02-10 12:20:35 +0000 |
commit | f1f0770d686a9fecfa51be3699469c287e1fd9c2 (patch) | |
tree | b790cc6273a4a84d83446cb53c5fb81d7bccf1af /Userland | |
parent | 373b46730230486210adfcc9a0c9484921f8ade0 (diff) | |
download | serenity-f1f0770d686a9fecfa51be3699469c287e1fd9c2.zip |
LibSQL: Do not crash when SELECTing from an empty table
The crash was caused by getting the first element of an empty vector.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibSQL/AST/Select.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibSQL/AST/Select.cpp b/Userland/Libraries/LibSQL/AST/Select.cpp index 55253c8b08..863f90cc50 100644 --- a/Userland/Libraries/LibSQL/AST/Select.cpp +++ b/Userland/Libraries/LibSQL/AST/Select.cpp @@ -69,8 +69,8 @@ Result Select::execute(ExecutionContext& context) const auto old_descriptor_size = descriptor->size(); descriptor->extend(table_def->to_tuple_descriptor()); - for (auto cartesian_row = rows.first(); cartesian_row.size() == old_descriptor_size; cartesian_row = rows.first()) { - rows.remove(0); + while (!rows.is_empty() && (rows.first().size() == old_descriptor_size)) { + auto cartesian_row = rows.take_first(); auto table_rows = TRY(context.database->select_all(*table_def)); for (auto& table_row : table_rows) { |