binary decode base64 "[binary encode base64 u]" => u, as expected
binary decode base64 "[binary encode base64 u] " => empty
Trailing space characters cause inner loop to run 4 times in "post-data-end" branch, increasing "cut" value each time, with 3 output bytes only. Thus the last byte of previous data is thrown away incorrectly.
The code is still too liberal, accepting illegal base64. It would be better to borrow a correct, well-tested implementation from somewhere else.