aboutsummaryrefslogtreecommitdiffstats
path: root/src/termcap.c
diff options
context:
space:
mode:
authorJoakim Verona2011-08-27 19:45:48 +0200
committerJoakim Verona2011-08-27 19:45:48 +0200
commit9fb7b0cab34a48a4c7b66abb6b8edc4ee20467b4 (patch)
treee94476d49f15747fcb9409d773702e88201855a4 /src/termcap.c
parentc7489583c30031c0ecfae9d20b20c149ca1935e9 (diff)
parentb75258b32810f3690442bddef2e10eef126d2d25 (diff)
downloademacs-9fb7b0cab34a48a4c7b66abb6b8edc4ee20467b4.tar.gz
emacs-9fb7b0cab34a48a4c7b66abb6b8edc4ee20467b4.zip
upstream
Diffstat (limited to 'src/termcap.c')
-rw-r--r--src/termcap.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/termcap.c b/src/termcap.c
index 96b9303d62d..6f24817fa72 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -480,7 +480,7 @@ tgetent (char *bp, const char *name)
480 /* If BP is malloc'd by us, make sure it is big enough. */ 480 /* If BP is malloc'd by us, make sure it is big enough. */
481 if (malloc_size) 481 if (malloc_size)
482 { 482 {
483 int offset1 = bp1 - bp, offset2 = tc_search_point - bp; 483 ptrdiff_t offset1 = bp1 - bp, offset2 = tc_search_point - bp;
484 malloc_size = offset1 + buf.size; 484 malloc_size = offset1 + buf.size;
485 bp = termcap_name = (char *) xrealloc (bp, malloc_size); 485 bp = termcap_name = (char *) xrealloc (bp, malloc_size);
486 bp1 = termcap_name + offset1; 486 bp1 = termcap_name + offset1;
@@ -619,7 +619,6 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end)
619 register char *end; 619 register char *end;
620 register int nread; 620 register int nread;
621 register char *buf = bufp->beg; 621 register char *buf = bufp->beg;
622 register char *tem;
623 622
624 if (!append_end) 623 if (!append_end)
625 append_end = bufp->ptr; 624 append_end = bufp->ptr;
@@ -636,14 +635,14 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end)
636 { 635 {
637 if (bufp->full == bufp->size) 636 if (bufp->full == bufp->size)
638 { 637 {
639 if ((PTRDIFF_MAX - 1) / 2 < bufp->size) 638 ptrdiff_t ptr_offset = bufp->ptr - buf;
640 memory_full (SIZE_MAX); 639 ptrdiff_t append_end_offset = append_end - buf;
641 bufp->size *= 2;
642 /* Add 1 to size to ensure room for terminating null. */ 640 /* Add 1 to size to ensure room for terminating null. */
643 tem = (char *) xrealloc (buf, bufp->size + 1); 641 ptrdiff_t size = bufp->size + 1;
644 bufp->ptr = (bufp->ptr - buf) + tem; 642 bufp->beg = buf = xpalloc (buf, &size, 1, -1, 1);
645 append_end = (append_end - buf) + tem; 643 bufp->size = size - 1;
646 bufp->beg = buf = tem; 644 bufp->ptr = buf + ptr_offset;
645 append_end = buf + append_end_offset;
647 } 646 }
648 } 647 }
649 else 648 else