summaryrefslogtreecommitdiff
path: root/src/if_cscope.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2015-02-10 18:34:01 +0100
committerBram Moolenaar <Bram@vim.org>2015-02-10 18:34:01 +0100
commit9abd5c6507154eabdfe8256940a24f090db0f533 (patch)
tree6c0fa11749df309d529fc35a5fd68cafd16c80a6 /src/if_cscope.c
parenta1d2c58985584116d20fa5e132137d8ff1a535f7 (diff)
downloadvim-git-9abd5c6507154eabdfe8256940a24f090db0f533.tar.gz
updated for version 7.4.624v7.4.624
Problem: May leak memory or crash when vim_realloc() returns NULL. Solution: Handle a NULL value properly. (Mike Williams)
Diffstat (limited to 'src/if_cscope.c')
-rw-r--r--src/if_cscope.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/if_cscope.c b/src/if_cscope.c
index ab31a0351..f72a96b9c 100644
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -1507,9 +1507,16 @@ cs_insert_filelist(fname, ppath, flags, sb)
}
else
{
+ csinfo_T *t_csinfo = csinfo;
+
/* Reallocate space for more connections. */
csinfo_size *= 2;
csinfo = vim_realloc(csinfo, sizeof(csinfo_T)*csinfo_size);
+ if (csinfo == NULL)
+ {
+ vim_free(t_csinfo);
+ csinfo_size = 0;
+ }
}
if (csinfo == NULL)
return -1;
@@ -2059,6 +2066,7 @@ cs_print_tags_priv(matches, cntxts, num_matches)
int num_matches;
{
char *buf = NULL;
+ char *t_buf;
int bufsize = 0; /* Track available bufsize */
int newsize = 0;
char *ptag;
@@ -2120,9 +2128,13 @@ cs_print_tags_priv(matches, cntxts, num_matches)
newsize = (int)(strlen(csfmt_str) + 16 + strlen(lno));
if (bufsize < newsize)
{
+ t_buf = buf;
buf = (char *)vim_realloc(buf, newsize);
if (buf == NULL)
+ {
bufsize = 0;
+ vim_free(t_buf);
+ }
else
bufsize = newsize;
}
@@ -2143,9 +2155,13 @@ cs_print_tags_priv(matches, cntxts, num_matches)
if (bufsize < newsize)
{
+ t_buf = buf;
buf = (char *)vim_realloc(buf, newsize);
if (buf == NULL)
+ {
bufsize = 0;
+ vim_free(t_buf);
+ }
else
bufsize = newsize;
}