summaryrefslogtreecommitdiff
path: root/src/netbeans.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/netbeans.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/netbeans.c')
-rw-r--r--src/netbeans.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/netbeans.c b/src/netbeans.c
index c3345447a..4f6cf2f47 100644
--- a/src/netbeans.c
+++ b/src/netbeans.c
@@ -1080,10 +1080,18 @@ nb_get_buf(int bufno)
{
if (bufno >= buf_list_size) /* grow list */
{
+ nbbuf_T *t_buf_list = buf_list;
+
incr = bufno - buf_list_size + 90;
buf_list_size += incr;
buf_list = (nbbuf_T *)vim_realloc(
buf_list, buf_list_size * sizeof(nbbuf_T));
+ if (buf_list == NULL)
+ {
+ vim_free(t_buf_list);
+ buf_list_size = 0;
+ return NULL;
+ }
vim_memset(buf_list + buf_list_size - incr, 0,
incr * sizeof(nbbuf_T));
}
@@ -3678,11 +3686,18 @@ addsigntype(
{
int incr;
int oldlen = globalsignmaplen;
+ char **t_globalsignmap = globalsignmap;
globalsignmaplen *= 2;
incr = globalsignmaplen - oldlen;
globalsignmap = (char **)vim_realloc(globalsignmap,
globalsignmaplen * sizeof(char *));
+ if (globalsignmap == NULL)
+ {
+ vim_free(t_globalsignmap);
+ globalsignmaplen = 0;
+ return;
+ }
vim_memset(globalsignmap + oldlen, 0, incr * sizeof(char *));
}
}
@@ -3708,11 +3723,18 @@ addsigntype(
{
int incr;
int oldlen = buf->signmaplen;
+ int *t_signmap = buf->signmap;
buf->signmaplen *= 2;
incr = buf->signmaplen - oldlen;
buf->signmap = (int *)vim_realloc(buf->signmap,
buf->signmaplen * sizeof(int));
+ if (buf->signmap == NULL)
+ {
+ vim_free(t_signmap);
+ buf->signmaplen = 0;
+ return;
+ }
vim_memset(buf->signmap + oldlen, 0, incr * sizeof(int));
}
}