dankogai / p5-encode

Encode - character encodings (for Perl 5.8 or better)
https://metacpan.org/release/Encode
37 stars 51 forks source link

Fix memory leak in function encode_method() #161

Closed pali closed 3 years ago

pali commented 3 years ago

Pull request https://github.com/dankogai/p5-encode/pull/72 fixed memory corruption but introduced a new memory leak as dst scalar is not mortal anymore and not every possible exit from every XS function properly release scalar's memory.

Fix this memory leak by making dst scalar mortal again. To not re-introduce that memory corruption, first store dst scalar into temporary variable and then save it into stack via ST(0) macro.

pali commented 3 years ago

It replaces commit 23978817a2c1ed13861167154e8eb3d829104b6b (which should be reverted).

dankogai commented 3 years ago

Thank you!