diff options
| author | Paul Eggert | 2011-07-28 10:05:33 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-07-28 10:05:33 -0700 |
| commit | 66606eea1f69d1b35dfc006c2901f2c7ca08d487 (patch) | |
| tree | 8249a45870851ca0291778d34c2380987165a2ce /src/alloc.c | |
| parent | 21956cce2b7b1d6a6c6777d800e63e62c2fbd594 (diff) | |
| download | emacs-66606eea1f69d1b35dfc006c2901f2c7ca08d487.tar.gz emacs-66606eea1f69d1b35dfc006c2901f2c7ca08d487.zip | |
* 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.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 6 |
1 files changed, 5 insertions, 1 deletions
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) | |||
| 3282 | int enough_free_memory = 0; | 3282 | int enough_free_memory = 0; |
| 3283 | if (SPARE_MEMORY < nbytes) | 3283 | if (SPARE_MEMORY < nbytes) |
| 3284 | { | 3284 | { |
| 3285 | void *p = malloc (SPARE_MEMORY); | 3285 | void *p; |
| 3286 | |||
| 3287 | MALLOC_BLOCK_INPUT; | ||
| 3288 | p = malloc (SPARE_MEMORY); | ||
| 3286 | if (p) | 3289 | if (p) |
| 3287 | { | 3290 | { |
| 3288 | free (p); | 3291 | free (p); |
| 3289 | enough_free_memory = 1; | 3292 | enough_free_memory = 1; |
| 3290 | } | 3293 | } |
| 3294 | MALLOC_UNBLOCK_INPUT; | ||
| 3291 | } | 3295 | } |
| 3292 | 3296 | ||
| 3293 | if (! enough_free_memory) | 3297 | if (! enough_free_memory) |