moved operation on bufptr in tap_handler causing dereferencing errors