The original patch (691c0315868511edff8048081e6e8b85c6653816) from Francis Herne got lost in the merge of the emulated command bar refactoring: I'm re-instating it here, this time with a test. Original commit message:
vimode: Don't crash when given a range for a nonexistent command. Patch by Francis Herne. When entering a range for a nonexistent command ,p is dereferenced before the null check. Move that check to before p is used. BUG: 360418 Differential Revision: D1684