Please don't copy strings returned from native implementation. I guess that there's no application that depends on exact return values. If we find such an application, than the function can be updated.
The tests are currently failing on Windows: https://testbot.winehq.org/JobDetails.pl?Key=137520
I think that something like https://gitlab.winehq.org/piotr/wine/-/commit/283b3be3f435ae3c3fdbefd378b971... should be good enough.