From 1bc6f594d3de8dbfb5c165835eaec99bd49327c8 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 11 Jun 1998 10:03:21 +0000 Subject: 1.1b9_25 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- gc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'gc.c') diff --git a/gc.c b/gc.c index 5347585a00..36d08e99c1 100644 --- a/gc.c +++ b/gc.c @@ -47,10 +47,13 @@ static unsigned long malloc_memories = 0; void * xmalloc(size) - unsigned long size; + int size; { void *mem; + if (size < 0) { + ArgError("negative allocation size (or too big)"); + } if (size == 0) size = 1; #if 0 malloc_memories += size; @@ -71,7 +74,7 @@ xmalloc(size) void * xcalloc(n, size) - unsigned long n, size; + int n, size; { void *mem; @@ -84,10 +87,13 @@ xcalloc(n, size) void * xrealloc(ptr, size) void *ptr; - unsigned long size; + int size; { void *mem; + if (size < 0) { + ArgError("negative re-allocation size"); + } if (!ptr) return xmalloc(size); mem = realloc(ptr, size); if (!mem) { -- cgit v1.2.3