mirror of
https://github.com/vim/vim.git
synced 2025-09-30 04:44:14 -04:00
patch 8.2.3331: Coverity warns for using value without boundary check
Problem: Coverity warns for using value without boundary check. Solution: Add a boundary check.
This commit is contained in:
@@ -755,6 +755,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3331,
|
||||||
/**/
|
/**/
|
||||||
3330,
|
3330,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -253,17 +253,18 @@ viminfo_readstring(
|
|||||||
int off, // offset for virp->vir_line
|
int off, // offset for virp->vir_line
|
||||||
int convert UNUSED) // convert the string
|
int convert UNUSED) // convert the string
|
||||||
{
|
{
|
||||||
char_u *retval;
|
char_u *retval = NULL;
|
||||||
char_u *s, *d;
|
char_u *s, *d;
|
||||||
long len;
|
long len;
|
||||||
|
|
||||||
if (virp->vir_line[off] == Ctrl_V && vim_isdigit(virp->vir_line[off + 1]))
|
if (virp->vir_line[off] == Ctrl_V && vim_isdigit(virp->vir_line[off + 1]))
|
||||||
{
|
{
|
||||||
len = atol((char *)virp->vir_line + off + 1);
|
len = atol((char *)virp->vir_line + off + 1);
|
||||||
|
if (len > 0 && len < 1000000)
|
||||||
retval = lalloc(len, TRUE);
|
retval = lalloc(len, TRUE);
|
||||||
if (retval == NULL)
|
if (retval == NULL)
|
||||||
{
|
{
|
||||||
// Line too long? File messed up? Skip next line.
|
// Invalid length, line too long, out of memory? Skip next line.
|
||||||
(void)vim_fgets(virp->vir_line, 10, virp->vir_fd);
|
(void)vim_fgets(virp->vir_line, 10, virp->vir_fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user