comparison 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
comparison
equal deleted inserted replaced
16428:6f69ef2913d7 16429:a1229400434a
1574 1574
1575 /* Prepend the BOM: "fffe" */ 1575 /* Prepend the BOM: "fffe" */
1576 if (string != NULL) 1576 if (string != NULL)
1577 { 1577 {
1578 tmpbuf = alloc(length + 2); 1578 tmpbuf = alloc(length + 2);
1579 tmpbuf[0] = 0xff; 1579 if (tmpbuf != NULL)
1580 tmpbuf[1] = 0xfe; 1580 {
1581 mch_memmove(tmpbuf + 2, string, (size_t)length); 1581 tmpbuf[0] = 0xff;
1582 vim_free(string); 1582 tmpbuf[1] = 0xfe;
1583 string = tmpbuf; 1583 mch_memmove(tmpbuf + 2, string, (size_t)length);
1584 length += 2; 1584 vim_free(string);
1585 string = tmpbuf;
1586 length += 2;
1587 }
1585 1588
1586 #if !GTK_CHECK_VERSION(3,0,0) 1589 #if !GTK_CHECK_VERSION(3,0,0)
1587 /* Looks redundant even for GTK2 because these values are 1590 /* Looks redundant even for GTK2 because these values are
1588 * overwritten by gtk_selection_data_set() that follows. */ 1591 * overwritten by gtk_selection_data_set() that follows. */
1589 selection_data->type = selection_data->target; 1592 selection_data->type = selection_data->target;
1604 if (tmpbuf != NULL) 1607 if (tmpbuf != NULL)
1605 { 1608 {
1606 tmpbuf[0] = motion_type; 1609 tmpbuf[0] = motion_type;
1607 STRCPY(tmpbuf + 1, p_enc); 1610 STRCPY(tmpbuf + 1, p_enc);
1608 mch_memmove(tmpbuf + l + 2, string, (size_t)length); 1611 mch_memmove(tmpbuf + l + 2, string, (size_t)length);
1612 length += l + 2;
1613 vim_free(string);
1614 string = tmpbuf;
1609 } 1615 }
1610 length += l + 2;
1611 vim_free(string);
1612 string = tmpbuf;
1613 type = vimenc_atom; 1616 type = vimenc_atom;
1614 } 1617 }
1615 1618
1616 /* gtk_selection_data_set_text() handles everything for us. This is 1619 /* gtk_selection_data_set_text() handles everything for us. This is
1617 * so easy and simple and cool, it'd be insane not to use it. */ 1620 * so easy and simple and cool, it'd be insane not to use it. */