Closed PiotrCzapla closed 1 month ago
The issue is a bit more complex than I've initially assumed since the structure can hold a reference to string managed by different part of the c code, so freeing it will cause a segfault later.
Thanks @PiotrCzapla for taking the time to submit the PR.
I remember I had a similar issue at that time that's why I used the malloc hack to copy the string into a new variable and assign it to the language parameter and it seems to be working.
I just tested it with different languages and I had no segfault! At least on my end!
Note that You should be using the language code from the supported lanaguages, ("de" for "German" for example)
But yes, setting the language param to None
will segfault obviously, this use case can be handled from Python and just turn the variable into an empty str instead.
Fixes the issue with params incorrectly handling language memory allocation I've added some test that fails without the fix. As well I fixed the tests so that they run on my mac with coreml support.