Open Bug 1493584 Opened 2 years ago Updated 1 year ago

move PrioEncoder initialization into a non-static method

Categories

(Firefox :: General, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: rhelmer, Assigned: rhelmer)

Details

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.

:chutten, are you likely to use the PrioEncoder DOM function or do you think you will use libprio directly from Telemetry?

Flags: needinfo?(chutten)

Oh, as I mention over in bug 1501132 comment#4, I plan on using PrioEncoder either as it is, or broken up into slightly smaller pieces so I can reach it without having a JS context.

Flags: needinfo?(chutten)
You need to log in before you can comment on or make changes to this bug.