comparison src/quickfix.c @ 9056:19d2dfb3f5e2 v7.4.1813

commit https://github.com/vim/vim/commit/9b4ebc692d77ca8ef90d72517347f74c2474dd3d Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 1 13:28:38 2016 +0200 patch 7.4.1813 Problem: Memory access error when running test_quickfix. Solution: Allocate one more byte. (Yegappan Lakshmanan)
author Christian Brabandt <cb@256bit.org>
date Sun, 01 May 2016 13:30:06 +0200
parents 0536d1469b67
children 616793d0412b
comparison
equal deleted inserted replaced
9055:8410027b1681 9056:19d2dfb3f5e2
543 * byte since it's not a NL character. 543 * byte since it's not a NL character.
544 */ 544 */
545 linelen = len > LINE_MAXLEN ? LINE_MAXLEN - 1 : len; 545 linelen = len > LINE_MAXLEN ? LINE_MAXLEN - 1 : len;
546 if (growbuf == NULL) 546 if (growbuf == NULL)
547 { 547 {
548 growbuf = alloc(linelen); 548 growbuf = alloc(linelen + 1);
549 growbufsiz = linelen; 549 growbufsiz = linelen;
550 } 550 }
551 else if (linelen > growbufsiz) 551 else if (linelen > growbufsiz)
552 { 552 {
553 growbuf = vim_realloc(growbuf, linelen); 553 growbuf = vim_realloc(growbuf, linelen + 1);
554 if (growbuf == NULL) 554 if (growbuf == NULL)
555 goto qf_init_end; 555 goto qf_init_end;
556 growbufsiz = linelen; 556 growbufsiz = linelen;
557 } 557 }
558 linebuf = growbuf; 558 linebuf = growbuf;
587 linelen = len; 587 linelen = len;
588 if (linelen > LINE_MAXLEN) 588 if (linelen > LINE_MAXLEN)
589 linelen = LINE_MAXLEN - 1; 589 linelen = LINE_MAXLEN - 1;
590 if (growbuf == NULL) 590 if (growbuf == NULL)
591 { 591 {
592 growbuf = alloc(linelen); 592 growbuf = alloc(linelen + 1);
593 growbufsiz = linelen; 593 growbufsiz = linelen;
594 } 594 }
595 else if (linelen > growbufsiz) 595 else if (linelen > growbufsiz)
596 { 596 {
597 if ((growbuf = vim_realloc(growbuf, 597 if ((growbuf = vim_realloc(growbuf,
598 linelen)) == NULL) 598 linelen + 1)) == NULL)
599 goto qf_init_end; 599 goto qf_init_end;
600 growbufsiz = linelen; 600 growbufsiz = linelen;
601 } 601 }
602 linebuf = growbuf; 602 linebuf = growbuf;
603 } 603 }
621 linelen = (int)STRLEN(p_buf); 621 linelen = (int)STRLEN(p_buf);
622 if (linelen > IOSIZE - 2) 622 if (linelen > IOSIZE - 2)
623 { 623 {
624 if (growbuf == NULL) 624 if (growbuf == NULL)
625 { 625 {
626 growbuf = alloc(linelen); 626 growbuf = alloc(linelen + 1);
627 growbufsiz = linelen; 627 growbufsiz = linelen;
628 } 628 }
629 else if (linelen > growbufsiz) 629 else if (linelen > growbufsiz)
630 { 630 {
631 if (linelen > LINE_MAXLEN) 631 if (linelen > LINE_MAXLEN)
632 linelen = LINE_MAXLEN - 1; 632 linelen = LINE_MAXLEN - 1;
633 if ((growbuf = vim_realloc(growbuf, linelen)) == NULL) 633 if ((growbuf = vim_realloc(growbuf, linelen + 1)) == NULL)
634 goto qf_init_end; 634 goto qf_init_end;
635 growbufsiz = linelen; 635 growbufsiz = linelen;
636 } 636 }
637 linebuf = growbuf; 637 linebuf = growbuf;
638 } 638 }