Thanks shadow for the report, and Melevir and thiderman for the patch. Backport of ec9d6b11 from master.