This is an off by one error: padding == 0 means no padding should be done at all.