mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* gc.c (ruby_xmalloc2): change check for integer overflow.
[ruby-dev:27399] * gc.c (ruby_xrealloc2): ditto. * eval.c (exec_under): avoid accessing ruby_frame->prev. [ruby-dev:27948] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
445d6076d8
commit
088fb2a36e
8 changed files with 54 additions and 30 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
Tue Dec 6 16:48:40 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* gc.c (ruby_xmalloc2): change check for integer overflow.
|
||||
[ruby-dev:27399]
|
||||
|
||||
* gc.c (ruby_xrealloc2): ditto.
|
||||
|
||||
Tue Dec 4 16:37:57 2005 Yuya Nishida <yuya@j96.org>
|
||||
|
||||
* eval.c (exec_under): avoid accessing ruby_frame->prev.
|
||||
[ruby-dev:27948]
|
||||
|
||||
Fri Dec 2 19:06:06 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||
|
||||
* dir.c (Compare): should not fold double byte alphabet on win9x.
|
||||
|
@ -15,6 +27,7 @@ Wed Nov 30 23:52:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
* parse.y (NEWHEAP, ADD2HEAP): set count after pointer was set.
|
||||
fixed: [ruby-dev:27896]
|
||||
|
||||
>>>>>>> 1.4819
|
||||
Wed Nov 30 13:43:07 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* misc/ruby-mode.el (ruby-expr-beg): support $! at the end of
|
||||
|
|
10
defines.h
10
defines.h
|
@ -48,11 +48,11 @@
|
|||
#define xrealloc2 ruby_xrealloc2
|
||||
#define xfree ruby_xfree
|
||||
|
||||
void *xmalloc(long);
|
||||
void *xmalloc2(long,long);
|
||||
void *xcalloc(long,long);
|
||||
void *xrealloc(void*,long);
|
||||
void *xrealloc2(void*,long,long);
|
||||
void *xmalloc(size_t);
|
||||
void *xmalloc2(size_t,size_t);
|
||||
void *xcalloc(size_t,size_t);
|
||||
void *xrealloc(void*,size_t);
|
||||
void *xrealloc2(void*,size_t,size_t);
|
||||
void xfree(void*);
|
||||
|
||||
#if SIZEOF_LONG_LONG > 0
|
||||
|
|
3
eval.c
3
eval.c
|
@ -5741,6 +5741,7 @@ rb_call0(VALUE klass, VALUE recv, ID id, ID oid,
|
|||
static VALUE
|
||||
rb_call(VALUE klass, VALUE recv, ID mid,
|
||||
int argc /* OK */, const VALUE *argv /* OK */, int scope)
|
||||
/* scope: 0=normal, 1=functional style, 2=variable style */
|
||||
{
|
||||
NODE *body; /* OK */
|
||||
int noex;
|
||||
|
@ -6259,7 +6260,7 @@ exec_under(VALUE (*func) (VALUE), VALUE under, VALUE cbase, VALUE args)
|
|||
VALUE val = Qnil; /* OK */
|
||||
int state;
|
||||
int mode;
|
||||
struct FRAME *f = ruby_frame->prev;
|
||||
struct FRAME *f = ruby_frame;
|
||||
|
||||
PUSH_CLASS(under);
|
||||
PUSH_FRAME();
|
||||
|
|
|
@ -595,6 +595,8 @@ yaml_org_handler( n, ref )
|
|||
return transferred;
|
||||
}
|
||||
|
||||
static void syck_node_mark( SyckNode *n );
|
||||
|
||||
/*
|
||||
* {native mode} node handler
|
||||
* - Converts data into native Ruby types
|
||||
|
@ -615,7 +617,8 @@ rb_syck_load_handler(p, n)
|
|||
/*
|
||||
* Create node,
|
||||
*/
|
||||
obj = rb_funcall( resolver, s_node_import, 1, Data_Wrap_Struct( cNode, NULL, NULL, n ) );
|
||||
obj = rb_funcall( resolver, s_node_import,
|
||||
1, Data_Wrap_Struct( cNode, syck_node_mark, NULL, n ) );
|
||||
|
||||
/*
|
||||
* ID already set, let's alter the symbol table to accept the new object
|
||||
|
@ -711,13 +714,14 @@ syck_mark_parser(parser)
|
|||
SyckParser *parser;
|
||||
{
|
||||
struct parser_xtra *bonus;
|
||||
rb_gc_mark(parser->root);
|
||||
rb_gc_mark(parser->root_on_error);
|
||||
rb_gc_mark_maybe(parser->root);
|
||||
rb_gc_mark_maybe(parser->root_on_error);
|
||||
if ( parser->bonus != NULL )
|
||||
{
|
||||
bonus = (struct parser_xtra *)parser->bonus;
|
||||
rb_gc_mark( bonus->data );
|
||||
rb_gc_mark( bonus->proc );
|
||||
rb_gc_mark( bonus->resolver );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1380,9 +1384,12 @@ syck_node_mark( n )
|
|||
SyckNode *n;
|
||||
{
|
||||
int i;
|
||||
if (!n) return;
|
||||
rb_gc_mark_maybe( n->id );
|
||||
switch ( n->kind )
|
||||
{
|
||||
case syck_seq_kind:
|
||||
if (!n->data.list) return;
|
||||
for ( i = 0; i < n->data.list->idx; i++ )
|
||||
{
|
||||
rb_gc_mark( syck_seq_read( n, i ) );
|
||||
|
@ -1390,6 +1397,7 @@ syck_node_mark( n )
|
|||
break;
|
||||
|
||||
case syck_map_kind:
|
||||
if (!n->data.pairs) return;
|
||||
for ( i = 0; i < n->data.pairs->idx; i++ )
|
||||
{
|
||||
rb_gc_mark( syck_map_read( n, map_key, i ) );
|
||||
|
@ -1397,6 +1405,7 @@ syck_node_mark( n )
|
|||
}
|
||||
break;
|
||||
}
|
||||
rb_gc_mark_maybe( n->shortcut );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1804,13 +1813,14 @@ syck_node_transform( self )
|
|||
SyckNode *n;
|
||||
SyckNode *orig_n;
|
||||
Data_Get_Struct(self, SyckNode, orig_n);
|
||||
t = Data_Wrap_Struct( cNode, syck_node_mark, NULL, 0 );
|
||||
|
||||
switch (orig_n->kind)
|
||||
{
|
||||
case syck_map_kind:
|
||||
{
|
||||
int i;
|
||||
n = syck_alloc_map();
|
||||
DATA_PTR(t) = n = syck_alloc_map();
|
||||
for ( i = 0; i < orig_n->data.pairs->idx; i++ )
|
||||
{
|
||||
syck_map_add( n, rb_funcall( syck_map_read( orig_n, map_key, i ), s_transform, 0 ),
|
||||
|
@ -1822,7 +1832,7 @@ syck_node_transform( self )
|
|||
case syck_seq_kind:
|
||||
{
|
||||
int i;
|
||||
n = syck_alloc_seq();
|
||||
DATA_PTR(t) = n = syck_alloc_seq();
|
||||
for ( i = 0; i < orig_n->data.list->idx; i++ )
|
||||
{
|
||||
syck_seq_add( n, rb_funcall( syck_seq_read( orig_n, i ), s_transform, 0 ) );
|
||||
|
@ -1831,7 +1841,7 @@ syck_node_transform( self )
|
|||
break;
|
||||
|
||||
case syck_str_kind:
|
||||
n = syck_new_str2( orig_n->data.str->ptr, orig_n->data.str->len, orig_n->data.str->style );
|
||||
DATA_PTR(t) = n = syck_new_str2( orig_n->data.str->ptr, orig_n->data.str->len, orig_n->data.str->style );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1843,7 +1853,6 @@ syck_node_transform( self )
|
|||
{
|
||||
n->anchor = syck_strndup( orig_n->anchor, strlen( orig_n->anchor ) );
|
||||
}
|
||||
t = Data_Wrap_Struct( cNode, NULL, NULL, n );
|
||||
n->id = t;
|
||||
t = rb_funcall( oDefaultResolver, s_node_import, 1, t );
|
||||
syck_free_node( n );
|
||||
|
@ -1946,6 +1955,7 @@ syck_mark_emitter(emitter)
|
|||
if ( emitter->bonus != NULL )
|
||||
{
|
||||
bonus = (struct emitter_xtra *)emitter->bonus;
|
||||
rb_gc_mark( bonus->oid );
|
||||
rb_gc_mark( bonus->data );
|
||||
rb_gc_mark( bonus->port );
|
||||
}
|
||||
|
|
16
gc.c
16
gc.c
|
@ -107,7 +107,7 @@ rb_memerror(void)
|
|||
}
|
||||
|
||||
void *
|
||||
ruby_xmalloc(long size)
|
||||
ruby_xmalloc(size_t size)
|
||||
{
|
||||
void *mem;
|
||||
|
||||
|
@ -134,17 +134,17 @@ ruby_xmalloc(long size)
|
|||
}
|
||||
|
||||
void *
|
||||
ruby_xmalloc2(long n, long size)
|
||||
ruby_xmalloc2(size_t n, size_t size)
|
||||
{
|
||||
long len = size * n;
|
||||
if (len < n || (n > 0 && len < size)) {
|
||||
if (n != 0 && size != len / n) {
|
||||
rb_raise(rb_eArgError, "malloc: possible integer overflow");
|
||||
}
|
||||
return ruby_xmalloc(len);
|
||||
}
|
||||
|
||||
void *
|
||||
ruby_xcalloc(long n, long size)
|
||||
ruby_xcalloc(size_t n, size_t size)
|
||||
{
|
||||
void *mem;
|
||||
|
||||
|
@ -155,7 +155,7 @@ ruby_xcalloc(long n, long size)
|
|||
}
|
||||
|
||||
void *
|
||||
ruby_xrealloc(void *ptr, long size)
|
||||
ruby_xrealloc(void *ptr, size_t size)
|
||||
{
|
||||
void *mem;
|
||||
|
||||
|
@ -179,10 +179,10 @@ ruby_xrealloc(void *ptr, long size)
|
|||
}
|
||||
|
||||
void *
|
||||
ruby_xrealloc2(void *ptr, long n, long size)
|
||||
ruby_xrealloc2(void *ptr, size_t n, size_t size)
|
||||
{
|
||||
long len = size * n;
|
||||
if (len < n || (n > 0 && len < size)) {
|
||||
size_t len = size * n;
|
||||
if (n != 0 && size != len / n) {
|
||||
rb_raise(rb_eArgError, "realloc: possible integer overflow");
|
||||
}
|
||||
return ruby_xrealloc(ptr, len);
|
||||
|
|
4
ruby.h
4
ruby.h
|
@ -41,8 +41,6 @@ extern "C" {
|
|||
#define PRINTF_ARGS(decl, string_index, first_to_check) decl
|
||||
#endif
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
@ -60,6 +58,8 @@ extern "C" {
|
|||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
/* need to include <ctype.h> to use these macros */
|
||||
#ifndef ISPRINT
|
||||
#define ISASCII(c) isascii((int)(unsigned char)(c))
|
||||
|
|
8
st.c
8
st.c
|
@ -18,9 +18,9 @@
|
|||
#define xrealloc ruby_xrealloc
|
||||
#define xfree ruby_xfree
|
||||
|
||||
void *xmalloc(long);
|
||||
void *xcalloc(long, long);
|
||||
void *xrealloc(void *, long);
|
||||
void *xmalloc(size_t);
|
||||
void *xcalloc(size_t, size_t);
|
||||
void *xrealloc(void *, size_t);
|
||||
void xfree(void *);
|
||||
#endif
|
||||
#endif
|
||||
|
@ -65,7 +65,7 @@ static struct st_hash_type type_strhash = {
|
|||
|
||||
static void rehash(st_table *);
|
||||
|
||||
#define alloc(type) (type*)xmalloc((unsigned)sizeof(type))
|
||||
#define alloc(type) (type*)xmalloc((size_t)sizeof(type))
|
||||
#define Calloc(n,s) (char*)xcalloc((n),(s))
|
||||
|
||||
#define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)((x),(y)) == 0)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#define RUBY_VERSION "1.9.0"
|
||||
#define RUBY_RELEASE_DATE "2005-12-02"
|
||||
#define RUBY_RELEASE_DATE "2005-12-06"
|
||||
#define RUBY_VERSION_CODE 190
|
||||
#define RUBY_RELEASE_CODE 20051202
|
||||
#define RUBY_RELEASE_CODE 20051206
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
#define RUBY_VERSION_MINOR 9
|
||||
#define RUBY_VERSION_TEENY 0
|
||||
#define RUBY_RELEASE_YEAR 2005
|
||||
#define RUBY_RELEASE_MONTH 12
|
||||
#define RUBY_RELEASE_DAY 2
|
||||
#define RUBY_RELEASE_DAY 6
|
||||
|
||||
RUBY_EXTERN const char ruby_version[];
|
||||
RUBY_EXTERN const char ruby_release_date[];
|
||||
|
|
Loading…
Reference in a new issue