Fix for #11036, updated with comments of @Stof in the issue