The caller has otherwise no way to know how long the string will be allocated or ability to free it. This fixes #2944.