1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-06 03:40:56 -08:00

* 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.
This commit is contained in:
Paul Eggert 2011-07-28 10:05:33 -07:00
parent 21956cce2b
commit 66606eea1f
2 changed files with 9 additions and 1 deletions

View file

@ -1,5 +1,9 @@
2011-07-28 Paul Eggert <eggert@cs.ucla.edu>
* 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.

View file

@ -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)