From: Paul Eggert Date: Thu, 28 Jul 2011 17:05:33 +0000 (-0700) Subject: * alloc.c (memory_full) [!SYNC_INPUT]: Fix signal-related race. X-Git-Tag: emacs-pretest-24.0.90~104^2~157^2~14 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=66606eea1f69d1b35dfc006c2901f2c7ca08d487;p=emacs.git * alloc.c (memory_full) [!SYNC_INPUT]: Fix signal-related race. Without this fix, if a signal arrives just after memory fills up, 'malloc' might be invoked reentrantly. --- diff --git a/src/ChangeLog b/src/ChangeLog index 045c4311789..eef9cede561 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2011-07-28 Paul Eggert + * alloc.c (memory_full) [!SYNC_INPUT]: Fix signal-related race. + Without this fix, if a signal arrives just after memory fills up, + 'malloc' might be invoked reentrantly. + * image.c (x_check_image_size) [!HAVE_X_WINDOWS]: Return 1. In other words, assume that every image size is allowed, on non-X hosts. This assumption is probably wrong, but it lets Emacs compile. diff --git a/src/alloc.c b/src/alloc.c index eb0185a8e35..b96fc1f0642 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3282,12 +3282,16 @@ memory_full (size_t nbytes) int enough_free_memory = 0; if (SPARE_MEMORY < nbytes) { - void *p = malloc (SPARE_MEMORY); + void *p; + + MALLOC_BLOCK_INPUT; + p = malloc (SPARE_MEMORY); if (p) { free (p); enough_free_memory = 1; } + MALLOC_UNBLOCK_INPUT; } if (! enough_free_memory)