Mercurial > vim
comparison src/ex_getln.c @ 30308:6b541aaaf39e v9.0.0490
patch 9.0.0490: using freed memory with cmdwin and BufEnter autocmd
Commit: https://github.com/vim/vim/commit/1c3dd8ddcba63c1af5112e567215b3cec2de11d0
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 17 19:43:23 2022 +0100
patch 9.0.0490: using freed memory with cmdwin and BufEnter autocmd
Problem: Using freed memory with cmdwin and BufEnter autocmd.
Solution: Make sure pointer to b_p_iminsert is still valid.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 17 Sep 2022 20:45:03 +0200 |
parents | be97adfeac3a |
children | 8496a2c45962 |
comparison
equal
deleted
inserted
replaced
30307:bf1d735c4bc9 | 30308:6b541aaaf39e |
---|---|
1585 #ifdef FEAT_EVAL | 1585 #ifdef FEAT_EVAL |
1586 int break_ctrl_c = FALSE; | 1586 int break_ctrl_c = FALSE; |
1587 #endif | 1587 #endif |
1588 expand_T xpc; | 1588 expand_T xpc; |
1589 long *b_im_ptr = NULL; | 1589 long *b_im_ptr = NULL; |
1590 buf_T *b_im_ptr_buf = NULL; // buffer where b_im_ptr is valid | |
1590 cmdline_info_T save_ccline; | 1591 cmdline_info_T save_ccline; |
1591 int did_save_ccline = FALSE; | 1592 int did_save_ccline = FALSE; |
1592 int cmdline_type; | 1593 int cmdline_type; |
1593 int wild_type; | 1594 int wild_type; |
1594 | 1595 |
1681 // Use ":lmap" mappings for search pattern and input(). | 1682 // Use ":lmap" mappings for search pattern and input(). |
1682 if (curbuf->b_p_imsearch == B_IMODE_USE_INSERT) | 1683 if (curbuf->b_p_imsearch == B_IMODE_USE_INSERT) |
1683 b_im_ptr = &curbuf->b_p_iminsert; | 1684 b_im_ptr = &curbuf->b_p_iminsert; |
1684 else | 1685 else |
1685 b_im_ptr = &curbuf->b_p_imsearch; | 1686 b_im_ptr = &curbuf->b_p_imsearch; |
1687 b_im_ptr_buf = curbuf; | |
1686 if (*b_im_ptr == B_IMODE_LMAP) | 1688 if (*b_im_ptr == B_IMODE_LMAP) |
1687 State |= MODE_LANGMAP; | 1689 State |= MODE_LANGMAP; |
1688 #ifdef HAVE_INPUT_METHOD | 1690 #ifdef HAVE_INPUT_METHOD |
1689 im_set_active(*b_im_ptr == B_IMODE_IM); | 1691 im_set_active(*b_im_ptr == B_IMODE_IM); |
1690 #endif | 1692 #endif |
2032 ui_cursor_shape(); // may show different cursor shape | 2034 ui_cursor_shape(); // may show different cursor shape |
2033 #endif | 2035 #endif |
2034 goto cmdline_not_changed; | 2036 goto cmdline_not_changed; |
2035 | 2037 |
2036 case Ctrl_HAT: | 2038 case Ctrl_HAT: |
2037 cmdline_toggle_langmap(b_im_ptr); | 2039 cmdline_toggle_langmap( |
2040 buf_valid(b_im_ptr_buf) ? b_im_ptr : NULL); | |
2038 goto cmdline_not_changed; | 2041 goto cmdline_not_changed; |
2039 | 2042 |
2040 // case '@': only in very old vi | 2043 // case '@': only in very old vi |
2041 case Ctrl_U: | 2044 case Ctrl_U: |
2042 // delete all characters left of the cursor | 2045 // delete all characters left of the cursor |
2542 if (!debug_mode) | 2545 if (!debug_mode) |
2543 may_trigger_modechanged(); | 2546 may_trigger_modechanged(); |
2544 #endif | 2547 #endif |
2545 | 2548 |
2546 #ifdef HAVE_INPUT_METHOD | 2549 #ifdef HAVE_INPUT_METHOD |
2547 if (b_im_ptr != NULL && *b_im_ptr != B_IMODE_LMAP) | 2550 if (b_im_ptr != NULL && buf_valid(b_im_ptr_buf) |
2551 && *b_im_ptr != B_IMODE_LMAP) | |
2548 im_save_status(b_im_ptr); | 2552 im_save_status(b_im_ptr); |
2549 im_set_active(FALSE); | 2553 im_set_active(FALSE); |
2550 #endif | 2554 #endif |
2551 setmouse(); | 2555 setmouse(); |
2552 #ifdef CURSOR_SHAPE | 2556 #ifdef CURSOR_SHAPE |