Fix 7582 stable6

backport of #7632

fixes #7582

@davivel @bantu @karlitschek @icewind1991 @schiesbn THX