Mercurial > vim
comparison src/misc1.c @ 6596:f8f2a61e538d v7.4.624
updated for version 7.4.624
Problem: May leak memory or crash when vim_realloc() returns NULL.
Solution: Handle a NULL value properly. (Mike Williams)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 10 Feb 2015 18:34:01 +0100 |
parents | 96a4fa8e530c |
children | 056809de0b29 |
comparison
equal
deleted
inserted
replaced
6595:09b0a3c8af26 | 6596:f8f2a61e538d |
---|---|
3429 maxlen = (buflen - 6 - len) / 3; | 3429 maxlen = (buflen - 6 - len) / 3; |
3430 if (buf == NULL) | 3430 if (buf == NULL) |
3431 buf = alloc(buflen); | 3431 buf = alloc(buflen); |
3432 else if (maxlen < 10) | 3432 else if (maxlen < 10) |
3433 { | 3433 { |
3434 char_u *t_buf = buf; | |
3435 | |
3434 /* Need some more space. This might happen when receiving a long | 3436 /* Need some more space. This might happen when receiving a long |
3435 * escape sequence. */ | 3437 * escape sequence. */ |
3436 buflen += 100; | 3438 buflen += 100; |
3437 buf = vim_realloc(buf, buflen); | 3439 buf = vim_realloc(buf, buflen); |
3440 if (buf == NULL) | |
3441 vim_free(t_buf); | |
3438 maxlen = (buflen - 6 - len) / 3; | 3442 maxlen = (buflen - 6 - len) / 3; |
3439 } | 3443 } |
3440 if (buf == NULL) | 3444 if (buf == NULL) |
3441 { | 3445 { |
3442 do_outofmem_msg((long_u)buflen); | 3446 do_outofmem_msg((long_u)buflen); |