Open Bug 1493584 Opened 2 years ago Updated 1 year ago

move PrioEncoder initialization into a non-static method


(Firefox :: General, enhancement, P3)





(Reporter: rhelmer, Assigned: rhelmer)


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:

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 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.