Mercurial > vim
diff src/gui_gtk_x11.c @ 16429:a1229400434a v8.1.1219
patch 8.1.1219: not checking for NULL return from alloc()
commit https://github.com/vim/vim/commit/6ee9658774942f7448af700fc04df0335796a3db
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 27 22:06:37 2019 +0200
patch 8.1.1219: not checking for NULL return from alloc()
Problem: Not checking for NULL return from alloc().
Solution: Add checks. (Martin Kunev, closes https://github.com/vim/vim/issues/4303, closes https://github.com/vim/vim/issues/4174)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 27 Apr 2019 22:15:05 +0200 |
parents | ddd82b1c9e9d |
children | 7ae2396cef62 |
line wrap: on
line diff
--- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -1576,12 +1576,15 @@ selection_get_cb(GtkWidget *widget U if (string != NULL) { tmpbuf = alloc(length + 2); - tmpbuf[0] = 0xff; - tmpbuf[1] = 0xfe; - mch_memmove(tmpbuf + 2, string, (size_t)length); - vim_free(string); - string = tmpbuf; - length += 2; + if (tmpbuf != NULL) + { + tmpbuf[0] = 0xff; + tmpbuf[1] = 0xfe; + mch_memmove(tmpbuf + 2, string, (size_t)length); + vim_free(string); + string = tmpbuf; + length += 2; + } #if !GTK_CHECK_VERSION(3,0,0) /* Looks redundant even for GTK2 because these values are @@ -1606,10 +1609,10 @@ selection_get_cb(GtkWidget *widget U tmpbuf[0] = motion_type; STRCPY(tmpbuf + 1, p_enc); mch_memmove(tmpbuf + l + 2, string, (size_t)length); + length += l + 2; + vim_free(string); + string = tmpbuf; } - length += l + 2; - vim_free(string); - string = tmpbuf; type = vimenc_atom; }