diff --git a/CHANGELOG.md b/CHANGELOG.md index b48abcdcda0..c149c5db384 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ ### Fixed * ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?) -* None. +* Performing a query like "{1, 2, 3, ...} IN list" where the array is longer than 8 and all elements are smaller than some values in list, the program would crash ([#1183](https://github.com/realm/realm-kotlin/issues/1183), v12.5.0) ### Breaking changes * None. diff --git a/src/realm/query_expression.hpp b/src/realm/query_expression.hpp index ba886d970cc..7059a45b673 100644 --- a/src/realm/query_expression.hpp +++ b/src/realm/query_expression.hpp @@ -483,7 +483,7 @@ class ValueBase { } else { if (left[left_idx] < right[right_idx]) { - if (any && left_idx < left_size) { + if (any && left_idx < left_size - 1) { left_idx++; } else { diff --git a/test/test_parser.cpp b/test/test_parser.cpp index 11ceeca75aa..0580e5c1c74 100644 --- a/test/test_parser.cpp +++ b/test/test_parser.cpp @@ -4035,6 +4035,7 @@ TEST(Parser_OperatorIN) verify_query(test_context, t, "ALL {8, 10} / 2 >= ANY items.price", 1); verify_query(test_context, t, "NONE {1, 2, 3} * 20 <= ANY items.price", 3); verify_query(test_context, t, "ANY {1, 2, 3, 4, 5, 6} + 2 == ANY items.price", 1); + verify_query(test_context, t, "ANY {0, 1, 2, 3, 5, 6, 7, 8, 9} == ANY items.price", 0); // No hit and all smaller // list property vs list property verify_query(test_context, t, "items.price IN items.price", 3);