Open Bug 1493584 Opened 2 years ago Updated 1 year ago
Encoder initialization into a non-static method
While looking at bug 1491737, I noticed that the way we're throwing errors from the static `encode` method could still potentially cause problems (memory leaks at least) if the key import were to fail (for any reason other than an invalid key, which bug 1492940 fixes), or if `Prio_init()` fails, since cleanup will never run: https://searchfox.org/mozilla-central/rev/0640ea80fbc8d48f8b197cd363e2535c95a15eb3/dom/prio/PrioEncoder.cpp#56-102 Currently, cleanup such as freeing memory and shutting down the NSS context (via `Prio_clear`) only happens when the `PrioEncoder` singleton that the `encode` method creates has its destructor called by `ClearOnShutdown`. In https://phabricator.services.mozilla.com/D6096#142476 Henri suggested: > Perhaps moving sPublicKeyA and sPublicKeyB to be fields mPublicKeyA and > mPublicKeyB and moving the initialization code into a non-static method.
You need to log in before you can comment on or make changes to this bug.