emp-toolkit / emp-ag2pc

Authenticated Garbling and Efficient Maliciously Secure Two-Party Computation
Other
23 stars 19 forks source link

Fix memory leak #32

Closed joerowell closed 2 years ago

joerowell commented 2 years ago

At the moment fpre.h leaks memory allocated in the constructor. Specifically, the constructor allocates memory like this:

for(int i = 0; i < THDS; ++i) {
      ...
      eq[i] = new Feq<T>(io[i], party);
      eq[THDS + i] = new Feq<T>(io2[i], party);
}

Whereas the destructor only frees the first half:

for(int i = 0; i < THDS; ++i) {
  ...
  delete eq[i];
}

This PR simply deletes the rest of the eq values. AddressSanitizer doesn't show any other leaks, so I think this is the only one.

wangxiao1254 commented 2 years ago

Thanks!