HomePhabricator
Diffusion Comm f09476d7d52e

[native] Avoid copy-constructing CryptoModule

Description

[native] Avoid copy-constructing CryptoModule

Summary:
See explanation here for why it's unsafe to copy-construct CryptoModule. Basically, the accountBuffer contains memory that represents an olm::Account, which includes members that are olm::Lists. olm::Lists contains a member that is a pointer to another member, which makes it unsafe to copy the accountBuffer wholesale.

This diff changes the code in NotificationsCryptoModule to construct its CryptoModule on the heap as a unique_ptr. We then pass that pointer around, avoiding any need to copy the CryptoModule.

The next diff will remove the copy constructor from CryptoModule to make sure nobody makes this mistake again.

Depends on D9560

Test Plan: I made sure notifs still worked in my local environment (iOS simulator running dev build, along with keyserver connected to APNs in dev mode)

Reviewers: marcin, tomek, bartek, atul

Reviewed By: marcin

Subscribers: wyilio

Differential Revision: https://phab.comm.dev/D9561

Details

Provenance
ashoatAuthored on Oct 22 2023, 7:01 AM
Reviewer
marcin
Differential Revision
D9561: [native] Avoid copy-constructing CryptoModule
Parents
rCOMM8a79b69fbd94: Revert "Revert "Implement stateful and deferrable notification decryption and…
Branches
Unknown
Tags
Unknown