move PrioEncoder initialization into a non-static method

NEW
Assigned to

Status

()

enhancement
P3
normal
8 months ago
3 months ago

People

(Reporter: rhelmer, Assigned: rhelmer)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Assignee

Description

8 months ago
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.
Assignee

Comment 1

3 months ago

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

Flags: needinfo?(chutten)

Comment 2

3 months ago

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.