summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0738
blob: be3f614bfb67311cb22ce09fb154d31d5723bc29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0738
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0738
Problem:    Using freed memory, for loop over blob leaks memory.
Solution:   Clear pointer after freeing memory.  Decrement reference count
            after for loop over blob.
Files:	    src/eval.c


*** ../vim-8.1.0737/src/eval.c	2019-01-13 15:41:58.937718637 +0100
--- src/eval.c	2019-01-13 16:01:12.357352208 +0100
***************
*** 2615,2620 ****
--- 2615,2622 ----
  		    clear_tv(&tv);
  		else
  		{
+ 		    // No need to increment the refcount, it's already set for
+ 		    // the blob being used in "tv".
  		    fi->fi_blob = b;
  		    fi->fi_bi = 0;
  		}
***************
*** 2684,2689 ****
--- 2686,2693 ----
  	list_rem_watch(fi->fi_list, &fi->fi_lw);
  	list_unref(fi->fi_list);
      }
+     if (fi != NULL && fi->fi_blob != NULL)
+ 	blob_unref(fi->fi_blob);
      vim_free(fi);
  }
  
***************
*** 4217,4224 ****
  		    {
  			if (!vim_isxdigit(bp[1]))
  			{
! 			    EMSG(_("E973: Blob literal should have an even number of hex characters"));
! 			    vim_free(blob);
  			    ret = FAIL;
  			    break;
  			}
--- 4221,4232 ----
  		    {
  			if (!vim_isxdigit(bp[1]))
  			{
! 			    if (blob != NULL)
! 			    {
! 				EMSG(_("E973: Blob literal should have an even number of hex characters"));
! 				ga_clear(&blob->bv_ga);
! 				VIM_CLEAR(blob);
! 			    }
  			    ret = FAIL;
  			    break;
  			}
***************
*** 4227,4237 ****
  					 (hex2nr(*bp) << 4) + hex2nr(*(bp+1)));
  		    }
  		    if (blob != NULL)
! 		    {
! 			++blob->bv_refcount;
! 			rettv->v_type = VAR_BLOB;
! 			rettv->vval.v_blob = blob;
! 		    }
  		    *arg = bp;
  		}
  		else
--- 4235,4241 ----
  					 (hex2nr(*bp) << 4) + hex2nr(*(bp+1)));
  		    }
  		    if (blob != NULL)
! 			rettv_blob_set(rettv, blob);
  		    *arg = bp;
  		}
  		else
*** ../vim-8.1.0737/src/version.c	2019-01-13 15:41:58.937718637 +0100
--- src/version.c	2019-01-13 15:46:25.263747024 +0100
***************
*** 797,798 ****
--- 797,800 ----
  {   /* Add new patch number below this line */
+ /**/
+     738,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
186. You overstay in the office so you can have more time surfing the net.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///