Bug 324797 - Crash on specific commands in normal VI mode
Summary: Crash on specific commands in normal VI mode
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: part (show other bugs)
Version: Git
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-11 14:40 UTC by Mehran Kholdi
Modified: 2013-09-20 22:07 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.11.2


Attachments
Fix the bug, and add test case (1.27 KB, patch)
2013-09-11 15:18 UTC, Mehran Kholdi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mehran Kholdi 2013-09-11 14:40:57 UTC
Sending "XP" command in VI mode, when the cursor is in the beginning of the line crashes kate.

Reproducible: Always

Steps to Reproduce:
1. Open up kate.
2. Write some text
3. Change to VI mode. (Ctrl + Meta + V)
4. Move the cursor to the very beginning of the file.
5. Press "XP" in normal vi mode.
Actual Results:  
Crash!
Comment 1 Mehran Kholdi 2013-09-11 14:42:59 UTC
I'm working on the bug myself, and will send the patch soon.
Comment 2 Mehran Kholdi 2013-09-11 15:18:17 UTC
Created attachment 82279 [details]
Fix the bug, and add test case

This should fix the bug, but I'm not sure if it does it the right way. The bug happened due to empty (but not null) register `"`, while pasting. According to the design of the code, it may be better to prevent the register from becoming an empty string.

Also added a single test case.
Comment 3 Dominik Haumann 2013-09-11 16:00:56 UTC
Mehran: Cool, thanks for the patch!
Simon: Can you take care of this?
Comment 4 Simon St James 2013-09-11 16:46:03 UTC
Git commit 4c60f7181b326e111fb71a3242b19516b0d02250 by Simon St James.
Committed on 11/09/2013 at 16:43.
Pushed by sstjames into branch 'master'.

Don't crash if we try to paste with an empty (but not null) register.

Thanks to Mehran Kholdi for the patch and test-case!

M  +1    -1    part/vimode/katevinormalmode.cpp
M  +1    -0    tests/vimode_test.cpp

http://commits.kde.org/kate/4c60f7181b326e111fb71a3242b19516b0d02250
Comment 5 Simon St James 2013-09-11 16:49:51 UTC
"According to the design of the code, it may be better to prevent the register from becoming an empty string."

The register starts off empty (there's not really a sensible non-empty default value to give a register) so your approach works best! I applied it without changes: thanks especially for taking time to give a test-case which fits in nicely with all the others!
Comment 6 Simon St James 2013-09-12 07:38:49 UTC
Git commit 8a70d96e33862290720cfa4d9f84310c66505bd4 by Simon St James.
Committed on 11/09/2013 at 16:43.
Pushed by sstjames into branch 'KDE/4.11'.

Don't crash if we try to paste with an empty (but not null) register.

Thanks to Mehran Kholdi for the patch and test-case!

cherry-picked from master.

M  +1    -1    part/vimode/katevinormalmode.cpp
M  +1    -0    tests/vimode_test.cpp

http://commits.kde.org/kate/8a70d96e33862290720cfa4d9f84310c66505bd4