From 84a03c9e7c1c8315af690ec274102c092111836c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Edelbo?= Date: Wed, 12 Jun 2024 16:02:22 +0200 Subject: [PATCH] Fix issue when clearing a Lst in an upgraded file --- CHANGELOG.md | 1 + src/realm/array_mixed.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97caa04c161..39ab449cf6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?) * Valgrind could report a branch on an uninitialized read when opening something that is not an encrypted Realm file as an encrypted Realm file ([PR #7789](https://github.com/realm/realm-core/pull/7789), since v14.10.0). * Opening an FLX realm asynchronously may not wait to download all data ([#7720](https://github.com/realm/realm-core/issues/7720), since FLX sync was introduced). +* Clearing a List of Mixed in an upgraded file would lead to an assertion failing ([#7771](https://github.com/realm/realm-core/issues/7771), since 14.0.0) ### Breaking changes * None. diff --git a/src/realm/array_mixed.cpp b/src/realm/array_mixed.cpp index ae580988b26..ce84c635423 100644 --- a/src/realm/array_mixed.cpp +++ b/src/realm/array_mixed.cpp @@ -215,7 +215,9 @@ void ArrayMixed::clear() Array::set(payload_idx_int, 0); Array::set(payload_idx_pair, 0); Array::set(payload_idx_str, 0); - Array::set(payload_idx_ref, 0); + if (Array::size() > payload_idx_ref) { + Array::set(payload_idx_ref, 0); + } if (Array::size() > payload_idx_key) { if (auto ref = Array::get_as_ref(payload_idx_key)) { Array::destroy(ref, m_composite.get_alloc());