microsoft / SEAL

Microsoft SEAL is an easy-to-use and powerful homomorphic encryption library.
https://www.microsoft.com/en-us/research/group/cryptography-research/
MIT License
3.62k stars 711 forks source link

add check for capacity size before allocating memory #704

Closed alexanderMathew closed 1 month ago

alexanderMathew commented 2 months ago

https://github.com/microsoft/SEAL/issues/693#issue-2337681575

Added a check in [/native/src/seal/dynarray.h] to see if capacity > capacity_ before memory allocation

kimlaine commented 1 month ago

This doesn't implement the correct/expected functionality. While it might work in most cases, it doesn't correspond to the description of the function in the comments. In particular, if the given capacity is smaller than the current size, the function should automatically resize the DynArray to have size corresponding to the new given capacity. With your edit, the function can no longer be used to reduce the size of the DynArray container at all, which is not right either.