diff options
| author | Gerd Moellmann | 2003-08-19 12:58:35 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2003-08-19 12:58:35 +0000 |
| commit | f4446bbf6f488f4ca028a513e37e95cbc79c91c4 (patch) | |
| tree | 23584cbf41402fefc46258c754b98452a11f52da | |
| parent | c5788e99dacf48ff1e013181c39ad1eecb722fad (diff) | |
| download | emacs-f4446bbf6f488f4ca028a513e37e95cbc79c91c4.tar.gz emacs-f4446bbf6f488f4ca028a513e37e95cbc79c91c4.zip | |
(lisp_align_malloc): Check for memory full when
allocating ablocks, which also avoids freeing a pointer into an
ablocks structure.
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/alloc.c | 32 |
2 files changed, 23 insertions, 15 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9ac972507e2..73e8de3aa71 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2003-08-19 Gerd Moellmann <gerd@gnu.org> | 1 | 2003-08-19 Gerd Moellmann <gerd@gnu.org> |
| 2 | 2 | ||
| 3 | * alloc.c (lisp_align_malloc): Check for memory full when | ||
| 4 | allocating ablocks, which also avoids freeing a pointer into an | ||
| 5 | ablocks structure. | ||
| 6 | |||
| 7 | * puresize.h (BASE_PURESIZE): Increase to 1100000. | ||
| 8 | |||
| 3 | * buffer.c (Fmove_overlay): Set overlay's next pointer | 9 | * buffer.c (Fmove_overlay): Set overlay's next pointer |
| 4 | unconditionally. | 10 | unconditionally. |
| 5 | 11 | ||
diff --git a/src/alloc.c b/src/alloc.c index 7f05cf77937..c4496b6ff7b 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -766,6 +766,23 @@ lisp_align_malloc (nbytes, type) | |||
| 766 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); | 766 | mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
| 767 | #endif | 767 | #endif |
| 768 | 768 | ||
| 769 | /* If the memory just allocated cannot be addressed thru a Lisp | ||
| 770 | object's pointer, and it needs to be, that's equivalent to | ||
| 771 | running out of memory. */ | ||
| 772 | if (type != MEM_TYPE_NON_LISP) | ||
| 773 | { | ||
| 774 | Lisp_Object tem; | ||
| 775 | char *end = (char *) base + ABLOCKS_BYTES - 1; | ||
| 776 | XSETCONS (tem, end); | ||
| 777 | if ((char *) XCONS (tem) != end) | ||
| 778 | { | ||
| 779 | lisp_malloc_loser = base; | ||
| 780 | free (base); | ||
| 781 | UNBLOCK_INPUT; | ||
| 782 | memory_full (); | ||
| 783 | } | ||
| 784 | } | ||
| 785 | |||
| 769 | /* Initialize the blocks and put them on the free list. | 786 | /* Initialize the blocks and put them on the free list. |
| 770 | Is `base' was not properly aligned, we can't use the last block. */ | 787 | Is `base' was not properly aligned, we can't use the last block. */ |
| 771 | for (i = 0; i < (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1); i++) | 788 | for (i = 0; i < (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1); i++) |
| @@ -788,21 +805,6 @@ lisp_align_malloc (nbytes, type) | |||
| 788 | val = free_ablock; | 805 | val = free_ablock; |
| 789 | free_ablock = free_ablock->x.next_free; | 806 | free_ablock = free_ablock->x.next_free; |
| 790 | 807 | ||
| 791 | /* If the memory just allocated cannot be addressed thru a Lisp | ||
| 792 | object's pointer, and it needs to be, | ||
| 793 | that's equivalent to running out of memory. */ | ||
| 794 | if (val && type != MEM_TYPE_NON_LISP) | ||
| 795 | { | ||
| 796 | Lisp_Object tem; | ||
| 797 | XSETCONS (tem, (char *) val + nbytes - 1); | ||
| 798 | if ((char *) XCONS (tem) != (char *) val + nbytes - 1) | ||
| 799 | { | ||
| 800 | lisp_malloc_loser = val; | ||
| 801 | free (val); | ||
| 802 | val = 0; | ||
| 803 | } | ||
| 804 | } | ||
| 805 | |||
| 806 | #if GC_MARK_STACK && !defined GC_MALLOC_CHECK | 808 | #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
| 807 | if (val && type != MEM_TYPE_NON_LISP) | 809 | if (val && type != MEM_TYPE_NON_LISP) |
| 808 | mem_insert (val, (char *) val + nbytes, type); | 810 | mem_insert (val, (char *) val + nbytes, type); |