diff options
| author | Paul Eggert | 2011-06-02 10:16:09 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-02 10:16:09 -0700 |
| commit | 037e65b496485cf3bd570a805bac787abac39cf3 (patch) | |
| tree | 343a49d60bc28ba9871c09442d7971d85a2901d7 /src | |
| parent | b3e945d3a47c5c64d84cb56594ff8c884acb1c37 (diff) | |
| parent | 57f53182c004f51e47818d70968a07579440eaff (diff) | |
| download | emacs-037e65b496485cf3bd570a805bac787abac39cf3.tar.gz emacs-037e65b496485cf3bd570a805bac787abac39cf3.zip | |
Merge: memory_full, gnutls improvements
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 16 | ||||
| -rw-r--r-- | src/alloc.c | 80 | ||||
| -rw-r--r-- | src/buffer.c | 6 | ||||
| -rw-r--r-- | src/editfns.c | 2 | ||||
| -rw-r--r-- | src/gnutls.c | 18 | ||||
| -rw-r--r-- | src/lisp.h | 4 | ||||
| -rw-r--r-- | src/menu.c | 2 | ||||
| -rw-r--r-- | src/minibuf.c | 2 | ||||
| -rw-r--r-- | src/xterm.c | 2 |
9 files changed, 90 insertions, 42 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 703976e4700..45d8e38738a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,21 @@ | |||
| 1 | 2011-06-02 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-06-02 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Malloc failure behavior now depends on size of allocation. | ||
| 4 | * alloc.c (buffer_memory_full, memory_full): New arg NBYTES. | ||
| 5 | * lisp.h: Change signatures accordingly. | ||
| 6 | * alloc.c, buffer.c, editfns.c, menu.c, minibuf.c, xterm.c: | ||
| 7 | All callers changed. (Bug#8762) | ||
| 8 | |||
| 9 | * gnutls.c: Use Emacs's memory allocators. | ||
| 10 | Without this change, the gnutls library would invoke malloc etc. | ||
| 11 | directly, which causes problems on non-SYNC_INPUT hosts, and which | ||
| 12 | runs afoul of improving memory_full behavior. (Bug#8761) | ||
| 13 | (fn_gnutls_global_set_mem_functions): New macro or function pointer. | ||
| 14 | (emacs_gnutls_global_init): Use it to specify xmalloc, xrealloc, | ||
| 15 | xfree instead of the default malloc, realloc, free. | ||
| 16 | (Fgnutls_boot): No need to check for memory allocation failure, | ||
| 17 | since xmalloc does that for us. | ||
| 18 | |||
| 3 | Remove arbitrary limit of 2**31 entries in hash tables. (Bug#8771) | 19 | Remove arbitrary limit of 2**31 entries in hash tables. (Bug#8771) |
| 4 | * category.c (hash_get_category_set): | 20 | * category.c (hash_get_category_set): |
| 5 | * ccl.c (ccl_driver): | 21 | * ccl.c (ccl_driver): |
diff --git a/src/alloc.c b/src/alloc.c index 8fcc6f91df9..0c18fca1755 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -467,7 +467,7 @@ display_malloc_warning (void) | |||
| 467 | /* Called if we can't allocate relocatable space for a buffer. */ | 467 | /* Called if we can't allocate relocatable space for a buffer. */ |
| 468 | 468 | ||
| 469 | void | 469 | void |
| 470 | buffer_memory_full (void) | 470 | buffer_memory_full (EMACS_INT nbytes) |
| 471 | { | 471 | { |
| 472 | /* If buffers use the relocating allocator, no need to free | 472 | /* If buffers use the relocating allocator, no need to free |
| 473 | spare_memory, because we may have plenty of malloc space left | 473 | spare_memory, because we may have plenty of malloc space left |
| @@ -477,7 +477,7 @@ buffer_memory_full (void) | |||
| 477 | malloc. */ | 477 | malloc. */ |
| 478 | 478 | ||
| 479 | #ifndef REL_ALLOC | 479 | #ifndef REL_ALLOC |
| 480 | memory_full (); | 480 | memory_full (nbytes); |
| 481 | #endif | 481 | #endif |
| 482 | 482 | ||
| 483 | /* This used to call error, but if we've run out of memory, we could | 483 | /* This used to call error, but if we've run out of memory, we could |
| @@ -673,7 +673,7 @@ xmalloc (size_t size) | |||
| 673 | MALLOC_UNBLOCK_INPUT; | 673 | MALLOC_UNBLOCK_INPUT; |
| 674 | 674 | ||
| 675 | if (!val && size) | 675 | if (!val && size) |
| 676 | memory_full (); | 676 | memory_full (size); |
| 677 | return val; | 677 | return val; |
| 678 | } | 678 | } |
| 679 | 679 | ||
| @@ -694,7 +694,8 @@ xrealloc (POINTER_TYPE *block, size_t size) | |||
| 694 | val = (POINTER_TYPE *) realloc (block, size); | 694 | val = (POINTER_TYPE *) realloc (block, size); |
| 695 | MALLOC_UNBLOCK_INPUT; | 695 | MALLOC_UNBLOCK_INPUT; |
| 696 | 696 | ||
| 697 | if (!val && size) memory_full (); | 697 | if (!val && size) |
| 698 | memory_full (size); | ||
| 698 | return val; | 699 | return val; |
| 699 | } | 700 | } |
| 700 | 701 | ||
| @@ -787,7 +788,7 @@ lisp_malloc (size_t nbytes, enum mem_type type) | |||
| 787 | 788 | ||
| 788 | MALLOC_UNBLOCK_INPUT; | 789 | MALLOC_UNBLOCK_INPUT; |
| 789 | if (!val && nbytes) | 790 | if (!val && nbytes) |
| 790 | memory_full (); | 791 | memory_full (nbytes); |
| 791 | return val; | 792 | return val; |
| 792 | } | 793 | } |
| 793 | 794 | ||
| @@ -934,7 +935,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type) | |||
| 934 | if (base == 0) | 935 | if (base == 0) |
| 935 | { | 936 | { |
| 936 | MALLOC_UNBLOCK_INPUT; | 937 | MALLOC_UNBLOCK_INPUT; |
| 937 | memory_full (); | 938 | memory_full (ABLOCKS_BYTES); |
| 938 | } | 939 | } |
| 939 | 940 | ||
| 940 | aligned = (base == abase); | 941 | aligned = (base == abase); |
| @@ -960,7 +961,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type) | |||
| 960 | lisp_malloc_loser = base; | 961 | lisp_malloc_loser = base; |
| 961 | free (base); | 962 | free (base); |
| 962 | MALLOC_UNBLOCK_INPUT; | 963 | MALLOC_UNBLOCK_INPUT; |
| 963 | memory_full (); | 964 | memory_full (SIZE_MAX); |
| 964 | } | 965 | } |
| 965 | } | 966 | } |
| 966 | #endif | 967 | #endif |
| @@ -2792,7 +2793,7 @@ allocate_vectorlike (EMACS_INT len) | |||
| 2792 | int word_size = sizeof p->contents[0]; | 2793 | int word_size = sizeof p->contents[0]; |
| 2793 | 2794 | ||
| 2794 | if ((SIZE_MAX - header_size) / word_size < len) | 2795 | if ((SIZE_MAX - header_size) / word_size < len) |
| 2795 | memory_full (); | 2796 | memory_full (SIZE_MAX); |
| 2796 | 2797 | ||
| 2797 | MALLOC_BLOCK_INPUT; | 2798 | MALLOC_BLOCK_INPUT; |
| 2798 | 2799 | ||
| @@ -3270,35 +3271,58 @@ make_event_array (register int nargs, Lisp_Object *args) | |||
| 3270 | ************************************************************************/ | 3271 | ************************************************************************/ |
| 3271 | 3272 | ||
| 3272 | 3273 | ||
| 3273 | /* Called if malloc returns zero. */ | 3274 | /* Called if malloc (NBYTES) returns zero. If NBYTES == SIZE_MAX, |
| 3275 | there may have been size_t overflow so that malloc was never | ||
| 3276 | called, or perhaps malloc was invoked successfully but the | ||
| 3277 | resulting pointer had problems fitting into a tagged EMACS_INT. In | ||
| 3278 | either case this counts as memory being full even though malloc did | ||
| 3279 | not fail. */ | ||
| 3274 | 3280 | ||
| 3275 | void | 3281 | void |
| 3276 | memory_full (void) | 3282 | memory_full (size_t nbytes) |
| 3277 | { | 3283 | { |
| 3278 | int i; | 3284 | /* Do not go into hysterics merely because a large request failed. */ |
| 3285 | int enough_free_memory = 0; | ||
| 3286 | if (SPARE_MEMORY < nbytes) | ||
| 3287 | { | ||
| 3288 | void *p = malloc (SPARE_MEMORY); | ||
| 3289 | if (p) | ||
| 3290 | { | ||
| 3291 | if (spare_memory[0]) | ||
| 3292 | free (p); | ||
| 3293 | else | ||
| 3294 | spare_memory[0] = p; | ||
| 3295 | enough_free_memory = 1; | ||
| 3296 | } | ||
| 3297 | } | ||
| 3279 | 3298 | ||
| 3280 | Vmemory_full = Qt; | 3299 | if (! enough_free_memory) |
| 3300 | { | ||
| 3301 | int i; | ||
| 3281 | 3302 | ||
| 3282 | memory_full_cons_threshold = sizeof (struct cons_block); | 3303 | Vmemory_full = Qt; |
| 3283 | 3304 | ||
| 3284 | /* The first time we get here, free the spare memory. */ | 3305 | memory_full_cons_threshold = sizeof (struct cons_block); |
| 3285 | for (i = 0; i < sizeof (spare_memory) / sizeof (char *); i++) | 3306 | |
| 3286 | if (spare_memory[i]) | 3307 | /* The first time we get here, free the spare memory. */ |
| 3287 | { | 3308 | for (i = 0; i < sizeof (spare_memory) / sizeof (char *); i++) |
| 3288 | if (i == 0) | 3309 | if (spare_memory[i]) |
| 3289 | free (spare_memory[i]); | 3310 | { |
| 3290 | else if (i >= 1 && i <= 4) | 3311 | if (i == 0) |
| 3291 | lisp_align_free (spare_memory[i]); | 3312 | free (spare_memory[i]); |
| 3292 | else | 3313 | else if (i >= 1 && i <= 4) |
| 3293 | lisp_free (spare_memory[i]); | 3314 | lisp_align_free (spare_memory[i]); |
| 3294 | spare_memory[i] = 0; | 3315 | else |
| 3295 | } | 3316 | lisp_free (spare_memory[i]); |
| 3317 | spare_memory[i] = 0; | ||
| 3318 | } | ||
| 3296 | 3319 | ||
| 3297 | /* Record the space now used. When it decreases substantially, | 3320 | /* Record the space now used. When it decreases substantially, |
| 3298 | we can refill the memory reserve. */ | 3321 | we can refill the memory reserve. */ |
| 3299 | #if !defined SYSTEM_MALLOC && !defined SYNC_INPUT | 3322 | #if !defined SYSTEM_MALLOC && !defined SYNC_INPUT |
| 3300 | bytes_used_when_full = BYTES_USED; | 3323 | bytes_used_when_full = BYTES_USED; |
| 3301 | #endif | 3324 | #endif |
| 3325 | } | ||
| 3302 | 3326 | ||
| 3303 | /* This used to call error, but if we've run out of memory, we could | 3327 | /* This used to call error, but if we've run out of memory, we could |
| 3304 | get infinite recursion trying to build the string. */ | 3328 | get infinite recursion trying to build the string. */ |
diff --git a/src/buffer.c b/src/buffer.c index 05bd129976f..e9ff8f492ba 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -328,7 +328,7 @@ even if it is dead. The return value is never nil. */) | |||
| 328 | alloc_buffer_text (b, BUF_GAP_SIZE (b) + 1); | 328 | alloc_buffer_text (b, BUF_GAP_SIZE (b) + 1); |
| 329 | UNBLOCK_INPUT; | 329 | UNBLOCK_INPUT; |
| 330 | if (! BUF_BEG_ADDR (b)) | 330 | if (! BUF_BEG_ADDR (b)) |
| 331 | buffer_memory_full (); | 331 | buffer_memory_full (BUF_GAP_SIZE (b) + 1); |
| 332 | 332 | ||
| 333 | b->pt = BEG; | 333 | b->pt = BEG; |
| 334 | b->begv = BEG; | 334 | b->begv = BEG; |
| @@ -4892,7 +4892,7 @@ alloc_buffer_text (struct buffer *b, size_t nbytes) | |||
| 4892 | if (p == NULL) | 4892 | if (p == NULL) |
| 4893 | { | 4893 | { |
| 4894 | UNBLOCK_INPUT; | 4894 | UNBLOCK_INPUT; |
| 4895 | memory_full (); | 4895 | memory_full (nbytes); |
| 4896 | } | 4896 | } |
| 4897 | 4897 | ||
| 4898 | b->text->beg = (unsigned char *) p; | 4898 | b->text->beg = (unsigned char *) p; |
| @@ -4920,7 +4920,7 @@ enlarge_buffer_text (struct buffer *b, EMACS_INT delta) | |||
| 4920 | if (p == NULL) | 4920 | if (p == NULL) |
| 4921 | { | 4921 | { |
| 4922 | UNBLOCK_INPUT; | 4922 | UNBLOCK_INPUT; |
| 4923 | memory_full (); | 4923 | memory_full (nbytes); |
| 4924 | } | 4924 | } |
| 4925 | 4925 | ||
| 4926 | BUF_BEG_ADDR (b) = (unsigned char *) p; | 4926 | BUF_BEG_ADDR (b) = (unsigned char *) p; |
diff --git a/src/editfns.c b/src/editfns.c index 8b48355fbfa..0e40fde9ca4 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3636,7 +3636,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3636 | { | 3636 | { |
| 3637 | EMACS_INT i; | 3637 | EMACS_INT i; |
| 3638 | if ((SIZE_MAX - formatlen) / sizeof (struct info) <= nargs) | 3638 | if ((SIZE_MAX - formatlen) / sizeof (struct info) <= nargs) |
| 3639 | memory_full (); | 3639 | memory_full (SIZE_MAX); |
| 3640 | SAFE_ALLOCA (info, struct info *, (nargs + 1) * sizeof *info + formatlen); | 3640 | SAFE_ALLOCA (info, struct info *, (nargs + 1) * sizeof *info + formatlen); |
| 3641 | discarded = (char *) &info[nargs + 1]; | 3641 | discarded = (char *) &info[nargs + 1]; |
| 3642 | for (i = 0; i < nargs + 1; i++) | 3642 | for (i = 0; i < nargs + 1; i++) |
diff --git a/src/gnutls.c b/src/gnutls.c index 5558fb9ee0b..9342ce7912e 100644 --- a/src/gnutls.c +++ b/src/gnutls.c | |||
| @@ -110,6 +110,10 @@ DEF_GNUTLS_FN (int, gnutls_error_is_fatal, (int)); | |||
| 110 | DEF_GNUTLS_FN (int, gnutls_global_init, (void)); | 110 | DEF_GNUTLS_FN (int, gnutls_global_init, (void)); |
| 111 | DEF_GNUTLS_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); | 111 | DEF_GNUTLS_FN (void, gnutls_global_set_log_function, (gnutls_log_func)); |
| 112 | DEF_GNUTLS_FN (void, gnutls_global_set_log_level, (int)); | 112 | DEF_GNUTLS_FN (void, gnutls_global_set_log_level, (int)); |
| 113 | DEF_GNUTLS_FN (void, gnutls_global_set_mem_functions, | ||
| 114 | (gnutls_alloc_function, gnutls_alloc_function, | ||
| 115 | gnutls_is_secure_function, gnutls_realloc_function, | ||
| 116 | gnutls_free_function)); | ||
| 113 | DEF_GNUTLS_FN (int, gnutls_handshake, (gnutls_session_t)); | 117 | DEF_GNUTLS_FN (int, gnutls_handshake, (gnutls_session_t)); |
| 114 | DEF_GNUTLS_FN (int, gnutls_init, (gnutls_session_t *, gnutls_connection_end_t)); | 118 | DEF_GNUTLS_FN (int, gnutls_init, (gnutls_session_t *, gnutls_connection_end_t)); |
| 115 | DEF_GNUTLS_FN (int, gnutls_priority_set_direct, | 119 | DEF_GNUTLS_FN (int, gnutls_priority_set_direct, |
| @@ -168,6 +172,7 @@ init_gnutls_functions (Lisp_Object libraries) | |||
| 168 | LOAD_GNUTLS_FN (library, gnutls_global_init); | 172 | LOAD_GNUTLS_FN (library, gnutls_global_init); |
| 169 | LOAD_GNUTLS_FN (library, gnutls_global_set_log_function); | 173 | LOAD_GNUTLS_FN (library, gnutls_global_set_log_function); |
| 170 | LOAD_GNUTLS_FN (library, gnutls_global_set_log_level); | 174 | LOAD_GNUTLS_FN (library, gnutls_global_set_log_level); |
| 175 | LOAD_GNUTLS_FN (library, gnutls_global_set_mem_functions); | ||
| 171 | LOAD_GNUTLS_FN (library, gnutls_handshake); | 176 | LOAD_GNUTLS_FN (library, gnutls_handshake); |
| 172 | LOAD_GNUTLS_FN (library, gnutls_init); | 177 | LOAD_GNUTLS_FN (library, gnutls_init); |
| 173 | LOAD_GNUTLS_FN (library, gnutls_priority_set_direct); | 178 | LOAD_GNUTLS_FN (library, gnutls_priority_set_direct); |
| @@ -213,6 +218,7 @@ init_gnutls_functions (Lisp_Object libraries) | |||
| 213 | #define fn_gnutls_global_init gnutls_global_init | 218 | #define fn_gnutls_global_init gnutls_global_init |
| 214 | #define fn_gnutls_global_set_log_function gnutls_global_set_log_function | 219 | #define fn_gnutls_global_set_log_function gnutls_global_set_log_function |
| 215 | #define fn_gnutls_global_set_log_level gnutls_global_set_log_level | 220 | #define fn_gnutls_global_set_log_level gnutls_global_set_log_level |
| 221 | #define fn_gnutls_global_set_mem_functions gnutls_global_set_mem_functions | ||
| 216 | #define fn_gnutls_handshake gnutls_handshake | 222 | #define fn_gnutls_handshake gnutls_handshake |
| 217 | #define fn_gnutls_init gnutls_init | 223 | #define fn_gnutls_init gnutls_init |
| 218 | #define fn_gnutls_priority_set_direct gnutls_priority_set_direct | 224 | #define fn_gnutls_priority_set_direct gnutls_priority_set_direct |
| @@ -582,7 +588,11 @@ emacs_gnutls_global_init (void) | |||
| 582 | int ret = GNUTLS_E_SUCCESS; | 588 | int ret = GNUTLS_E_SUCCESS; |
| 583 | 589 | ||
| 584 | if (!gnutls_global_initialized) | 590 | if (!gnutls_global_initialized) |
| 585 | ret = fn_gnutls_global_init (); | 591 | { |
| 592 | fn_gnutls_global_set_mem_functions (xmalloc, xmalloc, NULL, | ||
| 593 | xrealloc, xfree); | ||
| 594 | ret = fn_gnutls_global_init (); | ||
| 595 | } | ||
| 586 | gnutls_global_initialized = 1; | 596 | gnutls_global_initialized = 1; |
| 587 | 597 | ||
| 588 | return gnutls_make_error (ret); | 598 | return gnutls_make_error (ret); |
| @@ -768,8 +778,7 @@ one trustfile (usually a CA bundle). */) | |||
| 768 | { | 778 | { |
| 769 | GNUTLS_LOG (2, max_log_level, "allocating x509 credentials"); | 779 | GNUTLS_LOG (2, max_log_level, "allocating x509 credentials"); |
| 770 | x509_cred = XPROCESS (proc)->gnutls_x509_cred; | 780 | x509_cred = XPROCESS (proc)->gnutls_x509_cred; |
| 771 | if (fn_gnutls_certificate_allocate_credentials (&x509_cred) < 0) | 781 | fn_gnutls_certificate_allocate_credentials (&x509_cred); |
| 772 | memory_full (); | ||
| 773 | 782 | ||
| 774 | if (NUMBERP (verify_flags)) | 783 | if (NUMBERP (verify_flags)) |
| 775 | { | 784 | { |
| @@ -792,8 +801,7 @@ one trustfile (usually a CA bundle). */) | |||
| 792 | { | 801 | { |
| 793 | GNUTLS_LOG (2, max_log_level, "allocating anon credentials"); | 802 | GNUTLS_LOG (2, max_log_level, "allocating anon credentials"); |
| 794 | anon_cred = XPROCESS (proc)->gnutls_anon_cred; | 803 | anon_cred = XPROCESS (proc)->gnutls_anon_cred; |
| 795 | if (fn_gnutls_anon_allocate_client_credentials (&anon_cred) < 0) | 804 | fn_gnutls_anon_allocate_client_credentials (&anon_cred); |
| 796 | memory_full (); | ||
| 797 | } | 805 | } |
| 798 | else | 806 | else |
| 799 | { | 807 | { |
diff --git a/src/lisp.h b/src/lisp.h index 6e61d0b8bd3..a9e7354f9fc 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2684,8 +2684,8 @@ extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT); | |||
| 2684 | extern void reset_malloc_hooks (void); | 2684 | extern void reset_malloc_hooks (void); |
| 2685 | extern void uninterrupt_malloc (void); | 2685 | extern void uninterrupt_malloc (void); |
| 2686 | extern void malloc_warning (const char *); | 2686 | extern void malloc_warning (const char *); |
| 2687 | extern void memory_full (void) NO_RETURN; | 2687 | extern void memory_full (size_t) NO_RETURN; |
| 2688 | extern void buffer_memory_full (void) NO_RETURN; | 2688 | extern void buffer_memory_full (EMACS_INT) NO_RETURN; |
| 2689 | extern int survives_gc_p (Lisp_Object); | 2689 | extern int survives_gc_p (Lisp_Object); |
| 2690 | extern void mark_object (Lisp_Object); | 2690 | extern void mark_object (Lisp_Object); |
| 2691 | #if defined REL_ALLOC && !defined SYSTEM_MALLOC | 2691 | #if defined REL_ALLOC && !defined SYSTEM_MALLOC |
diff --git a/src/menu.c b/src/menu.c index e4338f349f6..7eda4c6ebb5 100644 --- a/src/menu.c +++ b/src/menu.c | |||
| @@ -178,7 +178,7 @@ static void | |||
| 178 | grow_menu_items (void) | 178 | grow_menu_items (void) |
| 179 | { | 179 | { |
| 180 | if ((INT_MAX - MENU_ITEMS_PANE_LENGTH) / 2 < menu_items_allocated) | 180 | if ((INT_MAX - MENU_ITEMS_PANE_LENGTH) / 2 < menu_items_allocated) |
| 181 | memory_full (); | 181 | memory_full (SIZE_MAX); |
| 182 | menu_items_allocated *= 2; | 182 | menu_items_allocated *= 2; |
| 183 | menu_items = larger_vector (menu_items, menu_items_allocated, Qnil); | 183 | menu_items = larger_vector (menu_items, menu_items_allocated, Qnil); |
| 184 | } | 184 | } |
diff --git a/src/minibuf.c b/src/minibuf.c index b3f157ba69a..ba8729bdff2 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -245,7 +245,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial, | |||
| 245 | len == size - 1 && line[len - 1] != '\n')) | 245 | len == size - 1 && line[len - 1] != '\n')) |
| 246 | { | 246 | { |
| 247 | if ((size_t) -1 / 2 < size) | 247 | if ((size_t) -1 / 2 < size) |
| 248 | memory_full (); | 248 | memory_full (SIZE_MAX); |
| 249 | size *= 2; | 249 | size *= 2; |
| 250 | line = (char *) xrealloc (line, size); | 250 | line = (char *) xrealloc (line, size); |
| 251 | } | 251 | } |
diff --git a/src/xterm.c b/src/xterm.c index 0923bbb717a..d6d6457f522 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -4225,7 +4225,7 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole) | |||
| 4225 | size_t old_nbytes = scroll_bar_windows_size * sizeof *scroll_bar_windows; | 4225 | size_t old_nbytes = scroll_bar_windows_size * sizeof *scroll_bar_windows; |
| 4226 | 4226 | ||
| 4227 | if ((size_t) -1 / sizeof *scroll_bar_windows < new_size) | 4227 | if ((size_t) -1 / sizeof *scroll_bar_windows < new_size) |
| 4228 | memory_full (); | 4228 | memory_full (SIZE_MAX); |
| 4229 | scroll_bar_windows = (struct window **) xrealloc (scroll_bar_windows, | 4229 | scroll_bar_windows = (struct window **) xrealloc (scroll_bar_windows, |
| 4230 | nbytes); | 4230 | nbytes); |
| 4231 | memset (&scroll_bar_windows[i], 0, nbytes - old_nbytes); | 4231 | memset (&scroll_bar_windows[i], 0, nbytes - old_nbytes); |