Ernie provided just the distraction Neville realized he needed. As the Slytherin cast the Imperius Curse on Ernie, Neville eased Megan against a desk and lunged at Crabbe, swatting the wand out of his hand just as he connected bodily with the much larger boy.
This was going to get uglier even than it already was.