Description
Passing a Perl variable to a method that takes a "decremented" argument results in a use-after-free. Example
perl -MClownfish -e 'Clownfish::Vector->new->push("abc")'
Analysis:
- A Clownfish "stack" string is created from the string value of the Perl variable.
- The stack string is passed to Vec_Push.
- The stack string is never incref'd.
- The copy-on-incref mechanism isn't invoked.
- When the Vector is destroyed, the stack string is decref'd, accessing random stack memory.
A possible solution is to forgo the stack string optimization for decremented arguments.