diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-04-27 22:06:37 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-04-27 22:06:37 +0200 |
commit | 6ee9658774942f7448af700fc04df0335796a3db (patch) | |
tree | 87f99c37e22f07e73e244da78686c7e59a8457f1 /src/gui_gtk_x11.c | |
parent | 00aa069db8132851a91cfc5ca7f58ef945c75c73 (diff) | |
download | vim-git-6ee9658774942f7448af700fc04df0335796a3db.tar.gz |
patch 8.1.1219: not checking for NULL return from alloc()v8.1.1219
Problem: Not checking for NULL return from alloc().
Solution: Add checks. (Martin Kunev, closes #4303, closes #4174)
Diffstat (limited to 'src/gui_gtk_x11.c')
-rw-r--r-- | src/gui_gtk_x11.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 5275026f8..f99d1fdcb 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -1576,12 +1576,15 @@ selection_get_cb(GtkWidget *widget UNUSED, 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 UNUSED, 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; } |