Mercurial > vim
diff src/popupwin.c @ 22600:d5ce7dd60dc1 v8.2.1848
patch 8.2.1848: crash when passing a NULL string or list to popup_settext()
Commit: https://github.com/vim/vim/commit/74f8eece5e481220e3c0767487c0bb59fa916ed6
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 15 19:10:56 2020 +0200
patch 8.2.1848: crash when passing a NULL string or list to popup_settext()
Problem: Crashyyyyy passing a NULL string or list to popup_settext().
Solution: Check for NULL pointers. (closes https://github.com/vim/vim/issues/7132)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 15 Oct 2020 19:15:03 +0200 |
parents | 909ce065e99a |
children | b5d68d8a5187 |
line wrap: on
line diff
--- a/src/popupwin.c +++ b/src/popupwin.c @@ -1595,14 +1595,16 @@ popup_set_buffer_text(buf_T *buf, typval // Add text to the buffer. if (text.v_type == VAR_STRING) { + char_u *s = text.vval.v_string; + // just a string - ml_append_buf(buf, 0, text.vval.v_string, (colnr_T)0, TRUE); + ml_append_buf(buf, 0, s == NULL ? (char_u *)"" : s, (colnr_T)0, TRUE); } else { list_T *l = text.vval.v_list; - if (l->lv_len > 0) + if (l != NULL && l->lv_len > 0) { if (l->lv_first->li_tv.v_type == VAR_STRING) // list of strings