fix padding miscalculation, thanks JaeTea666, fixes #17571
(cherry picked from commit 2ec779c9f75fc399cb3883d05964fa3183b00ecf)