vim-patch:8.2.3756: might crash when callback is not valid

Problem:    might crash when callback is not valid.
Solution:   Check for valid callback. (Yegappan Lakshmanan, closes vim/vim#9293)

4dc24eb5ad

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
zeertzjq
2022-11-07 11:04:33 +08:00
parent 42e44d6d33
commit d7bd7f13a8
7 changed files with 42 additions and 10 deletions

View File

@@ -2233,7 +2233,7 @@ static Callback tsrfu_cb; ///< 'thesaurusfunc' callback function
static void copy_global_to_buflocal_cb(Callback *globcb, Callback *bufcb)
{
callback_free(bufcb);
if (globcb->data.funcref != NULL && *globcb->data.funcref != NUL) {
if (globcb->type != kCallbackNone) {
callback_copy(bufcb, globcb);
}
}
@@ -2290,11 +2290,9 @@ int set_thesaurusfunc_option(void)
if (*curbuf->b_p_tsrfu != NUL) {
// buffer-local option set
callback_free(&curbuf->b_tsrfu_cb);
retval = option_set_callback_func(curbuf->b_p_tsrfu, &curbuf->b_tsrfu_cb);
} else {
// global option set
callback_free(&tsrfu_cb);
retval = option_set_callback_func(p_tsrfu, &tsrfu_cb);
}