discord / erlpack

High Performance Erlang Term Format Packer
MIT License
220 stars 65 forks source link

[erlpack] Ban same-encoder reentrancy #56

Closed ypisetsky closed 1 year ago

ypisetsky commented 2 years ago

The encoder_hook feature allows for arbitrary python code to be called while an ErlangTermEncoder assumes that it is able to muck with its memory at will. This is usually fine, but if someone were to attempt to pack something with the same encoder instance, it would clobber the previous encoding attempt. We track this situation with a flag and bail out loudly in this situation.