From fe120ac1f118eb009acb76d2d7a7d6934215dcd4 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 21 Apr 2016 20:59:39 +0000 Subject: * gc.c (objspace_malloc_prepare): remove size check because it is used by objspace_xmalloc and objspace_xcalloc. objspace_xmalloc introduces its own check in this commit. objspace_xcalloc checks with xmalloc2_size (ruby_xmalloc2_size). * gc.c (objspace_xmalloc0): common xmalloc function. * gc.c (objspace_xmalloc): introduce its own size check. * gc.c (objspace_xmalloc2): separated from ruby_xmalloc2 to clarify the layer who has the responsibility to check the size. * gc.c (objspace_xrealloc): remove duplicated size check. * gc.c (ruby_xmalloc2): use objspace_xmalloc2. * include/ruby/ruby.h (ruby_xmalloc2_size): follow the size limit as SSIZE_MAX. Note that ISO C says size_t is unsigned integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- include/ruby/ruby.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/ruby/ruby.h') diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index c41465adef..5c942c95ce 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -1611,7 +1611,7 @@ NORETURN(void ruby_malloc_size_overflow(size_t, size_t)); static inline size_t ruby_xmalloc2_size(const size_t count, const size_t elsize) { - if (count > SIZE_MAX / elsize) { + if (count > SSIZE_MAX / elsize) { ruby_malloc_size_overflow(count, elsize); } return count * elsize; -- cgit v1.2.3