diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-10 14:25:03 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-10 14:25:03 +0000 |
commit | 849bf24abff3a7e02b7ed4ebe3f3810dc8820040 (patch) | |
tree | c6eb2834f3e83a7b5107cbbd49f09b4c9a156f0c /gc.c | |
parent | 525844f2578fbaf7b06c5bf7a1f36741fa149fbb (diff) | |
download | ruby-849bf24abff3a7e02b7ed4ebe3f3810dc8820040.tar.gz |
gc.c: check of size in ruby_sized_xrealloc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -7880,7 +7880,7 @@ objspace_xrealloc(rb_objspace_t *objspace, void *ptr, size_t new_size, size_t ol { void *mem; - if (!ptr) return objspace_xmalloc(objspace, new_size); + if (!ptr) return objspace_xmalloc0(objspace, new_size); /* * The behavior of realloc(ptr, 0) is implementation defined. @@ -7979,6 +7979,10 @@ ruby_xcalloc(size_t n, size_t size) void * ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) { + if ((ssize_t)new_size < 0) { + negative_size_allocation_error("too large allocation size"); + } + return objspace_xrealloc(&rb_objspace, ptr, new_size, old_size); } |