8000 Zero-initialize realm_error_t when converting from Status by jbreams · Pull Request #7154 · realm/realm-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Zero-initialize realm_error_t when converting from Status #7154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* `Set::assign_intersection()` on `Set<StringData>`, `Set<BinaryData>`, and `Set<Mixed>` containing string or binary would cause a use-after-free if a set was intersected with itself ([PR #7144](https://github.com/realm/realm-core/pull/7144), since v10.0.0).
* Set algebra on `Set<StringData>` and `Set<BinaryData>` gave incorrect results when used on platforms where `char` is signed ([#7135](https://github.com/realm/realm-core/issues/7135), since v13.23.3).
* Errors encountered while reapplying local changes for client reset recovery on partition-based sync Realms would result in the client reset attempt not being recorded, possibly resulting in an endless loop of attempting and failing to automatically recover the client reset. Flexible sync and errors from the server after completing the local recovery were handled correctly ([PR #7149](https://github.com/realm/realm-core/pull/7149), since v10.2.0).
* Some fields in `realm_error_t` were uninitialized and contained invalid values when being converted from sync errors - now they should properly be nullptr ([PR #7154](https://github.com/realm/realm-core/pull/7154), since v13.18.0)
* Automatic client reset recovery would duplicate insertions in a list when recovering a write which made an unrecoverable change to a list (i.e. modifying or deleting a pre-existing entry), followed by a subscription change, followed by a write which added an entry to the list ([PR #7155](https://github.com/realm/realm-core/pull/7155), since v12.3.0).

### Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion src/realm/object-store/c_api/conversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ static inline realm_version_id_t to_capi(const VersionID& v)

static inline realm_error_t to_capi(const Status& s)
{
realm_error_t err;
realm_error_t err = {};
err.error = static_cast<realm_errno_e>(s.code());
err.categories = static_cast<realm_error_category_e>(ErrorCodes::error_categories(s.code()).value());
err.message = s.reason().c_str();
Expand Down
10 changes: 10 additions & 0 deletions test/object-store/c_api/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,16 @@ TEST_CASE("C API (non-database)", "[c_api]") {
}
}

SECTION("realm_error_t is properly initialized from Status") {
Status status(ErrorCodes::RuntimeError, "I am a runtime error!");
realm_error_t c_err = c_api::to_capi(status);
REQUIRE(c_err.error == RLM_ERR_RUNTIME);
REQUIRE(c_err.message == status.reason());
REQUIRE(c_err.categories == RLM_ERR_CAT_RUNTIME);
REQUIRE(c_err.path == nullptr);
REQUIRE(c_err.usercode_error == nullptr);
}

#if REALM_ENABLE_SYNC
SECTION("realm_app_config_t") {
const uint64_t request_timeout = 2500;
Expand Down
0