From 21532667504895f38a433d23f27bdcad9f989dd5 Mon Sep 17 00:00:00 2001 From: Karl Heuer Date: Sat, 27 Sep 1997 16:01:00 +0000 Subject: [PATCH] (relinquish): When returning memory to the system, watch out for the original data segment boundary. --- src/ralloc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ralloc.c b/src/ralloc.c index d1ce3be24fc..183db755412 100644 --- a/src/ralloc.c +++ b/src/ralloc.c @@ -363,7 +363,18 @@ relinquish () } if ((*real_morecore) (- excess) == 0) - abort (); + { + /* If the system didn't want that much memory back, adjust + the end of the last heap to reflect that. This can occur + if break_value is still within the original data segment. */ + last_heap->end += excess; + /* Make sure that the result of the adjustment is accurate. + It should be, for the else clause above; the other case, + which returns the entire last heap to the system, seems + unlikely to trigger this mode of failure. */ + if (last_heap->end != (*real_morecore) (0)) + abort (); + } } } -- 2.39.2