Skip to content

Commit

Permalink
Merge pull request #3190 from realm/kk-crash-indexofobject
Browse files Browse the repository at this point in the history
Crash called "indexOfObject" method to RLMResults made ​​from RLMArrayy, when the object wasn't found.
  • Loading branch information
tgoyne committed Feb 10, 2016
2 parents fb7ae55 + 7e66c2c commit 65a33b1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Fix a crash when deleting an object containing an `RLMArray`/`List` with
active notification blocks.
* Fix duplicate file warnings when building via CocoaPods.
* Fix crash or incorrect results when calling `indexOfObject:` on an
`RLMResults` derived from an `RLMArray`.

0.98.0 Release notes (2016-02-04)
=============================================================
Expand Down
3 changes: 0 additions & 3 deletions Realm/ObjectStore/results.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,6 @@ size_t Results::index_of(size_t row_ndx)
case Mode::Table:
return row_ndx;
case Mode::Query:
if (!m_sort)
return m_query.count(row_ndx, row_ndx + 1) ? m_query.count(0, row_ndx) : not_found;
REALM_FALLTHROUGH;
case Mode::TableView:
update_tableview();
return m_table_view.find_by_source_ndx(row_ndx);
Expand Down
4 changes: 4 additions & 0 deletions Realm/Tests/ArrayPropertyTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ - (void)testIndexOfObject

// invalid object
XCTAssertThrows([company.employees indexOfObject:(EmployeeObject *)company]);

RLMResults *employees = [company.employees objectsWhere:@"age = %@", @40];
XCTAssertEqual(0U, [employees indexOfObject:po1]);
XCTAssertEqual((NSUInteger)NSNotFound, [employees indexOfObject:po3]);
}

- (void)testIndexOfObjectWhere
Expand Down

0 comments on commit 65a33b1

Please sign in to comment.