Fix to prevent infinite loop

There's a condition when packed.length > bufsize that an infinite loop will happen when 'redo' is called.