Mercurial > vim
comparison src/map.c @ 28614:9ae2c32841fb v8.2.4831
patch 8.2.4831: crash when using maparg() and unmapping simplified keys
Commit: https://github.com/vim/vim/commit/2c8a7ebdad9da017bfb6dc8a0f46acea77ec2e17
Author: zeertzjq <zeertzjq@outlook.com>
Date: Tue Apr 26 21:36:21 2022 +0100
patch 8.2.4831: crash when using maparg() and unmapping simplified keys
Problem: Crash when using maparg() and unmapping simplified keys.
Solution: Do not keep a mapblock pointer. (closes https://github.com/vim/vim/issues/10294)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 26 Apr 2022 22:45:03 +0200 |
parents | 9ae7ccd90041 |
children | 38f7a132bba3 |
comparison
equal
deleted
inserted
replaced
28613:a56f5442fd9a | 28614:9ae2c32841fb |
---|---|
2323 int did_simplify = FALSE; | 2323 int did_simplify = FALSE; |
2324 char_u *rhs; | 2324 char_u *rhs; |
2325 int mode; | 2325 int mode; |
2326 int abbr = FALSE; | 2326 int abbr = FALSE; |
2327 int get_dict = FALSE; | 2327 int get_dict = FALSE; |
2328 mapblock_T *mp; | 2328 mapblock_T *mp = NULL; |
2329 mapblock_T *mp_simplified = NULL; | |
2330 int buffer_local; | 2329 int buffer_local; |
2331 int flags = REPTERM_FROM_PART | REPTERM_DO_LT; | 2330 int flags = REPTERM_FROM_PART | REPTERM_DO_LT; |
2332 | 2331 |
2333 // return empty string for failure | 2332 // return empty string for failure |
2334 rettv->v_type = VAR_STRING; | 2333 rettv->v_type = VAR_STRING; |
2360 &mp, &buffer_local); | 2359 &mp, &buffer_local); |
2361 if (did_simplify) | 2360 if (did_simplify) |
2362 { | 2361 { |
2363 // When the lhs is being simplified the not-simplified keys are | 2362 // When the lhs is being simplified the not-simplified keys are |
2364 // preferred for printing, like in do_map(). | 2363 // preferred for printing, like in do_map(). |
2365 // The "rhs" and "buffer_local" values are not expected to change. | |
2366 mp_simplified = mp; | |
2367 (void)replace_termcodes(keys, &alt_keys_buf, | 2364 (void)replace_termcodes(keys, &alt_keys_buf, |
2368 flags | REPTERM_NO_SIMPLIFY, NULL); | 2365 flags | REPTERM_NO_SIMPLIFY, NULL); |
2369 rhs = check_map(alt_keys_buf, mode, exact, FALSE, abbr, &mp, | 2366 rhs = check_map(alt_keys_buf, mode, exact, FALSE, abbr, &mp, |
2370 &buffer_local); | 2367 &buffer_local); |
2371 } | 2368 } |
2382 } | 2379 } |
2383 | 2380 |
2384 } | 2381 } |
2385 else if (rettv_dict_alloc(rettv) != FAIL && rhs != NULL) | 2382 else if (rettv_dict_alloc(rettv) != FAIL && rhs != NULL) |
2386 mapblock2dict(mp, rettv->vval.v_dict, | 2383 mapblock2dict(mp, rettv->vval.v_dict, |
2387 did_simplify ? mp_simplified->m_keys : NULL, buffer_local); | 2384 did_simplify ? keys_simplified : NULL, buffer_local); |
2388 | 2385 |
2389 vim_free(keys_buf); | 2386 vim_free(keys_buf); |
2390 vim_free(alt_keys_buf); | 2387 vim_free(alt_keys_buf); |
2391 } | 2388 } |
2392 | 2389 |