Page MenuHomePhabricator

[native] Avoid copy-constructing CryptoModule
ClosedPublic

Authored by ashoat on Oct 22 2023, 9:05 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 17, 3:11 AM
Unknown Object (File)
Tue, Dec 17, 3:11 AM
Unknown Object (File)
Tue, Dec 17, 3:11 AM
Unknown Object (File)
Tue, Dec 17, 3:11 AM
Unknown Object (File)
Tue, Dec 17, 3:08 AM
Unknown Object (File)
Sat, Dec 14, 4:06 PM
Unknown Object (File)
Dec 6 2024, 7:06 AM
Unknown Object (File)
Dec 1 2024, 6:50 AM
Subscribers

Details

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)

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable