From 82178a552907e413a09f5dfe646fb3e876f4011c Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 15 Aug 2000 09:04:32 +0000 Subject: [PATCH] matz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ env.h | 4 ++++ eval.c | 6 ++++-- lib/net/ftp.rb | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3c9627b1c..f74ef95126 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Tue Aug 15 17:30:59 2000 Yukihiro Matsumoto + + * eval.c (frame_dup): should set flag FRAME_MALLOC after + argv allocation. + + * eval.c (blk_free): should not free argv if GC was called before + frame_dup. + Tue Aug 15 16:08:40 2000 WATANABE Hirofumi * configure.in: add ac_cv_func_times=yes for mingw32. diff --git a/env.h b/env.h index 586d66c32b..3669baa33e 100644 --- a/env.h +++ b/env.h @@ -25,10 +25,14 @@ extern struct FRAME { char *file; int line; int iter; + int flags; } *ruby_frame; void rb_gc_mark_frame _((struct FRAME *)); +#define FRAME_ALLOCA 0 +#define FRAME_MALLOC 1 + extern struct SCOPE { struct RBasic super; ID *local_tbl; diff --git a/eval.c b/eval.c index 7ff72995c2..42ca67efc7 100644 --- a/eval.c +++ b/eval.c @@ -505,6 +505,7 @@ static struct SCOPE *top_scope; _frame.cbase = ruby_frame->cbase; \ _frame.argc = 0; \ _frame.argv = 0; \ + _frame.flags = FRAME_ALLOCA; \ ruby_frame = &_frame; \ #define POP_FRAME() \ @@ -5682,7 +5683,7 @@ blk_free(data) frame = data->frame.prev; while (frame) { - if (frame->argc > 0) + if (frame->argc > 0 && (frame->flags & FRAME_MALLOC)) free(frame->argv); tmp = frame; frame = frame->prev; @@ -5728,6 +5729,7 @@ frame_dup(frame) argv = ALLOC_N(VALUE, frame->argc); MEMCPY(argv, frame->argv, VALUE, frame->argc); frame->argv = argv; + frame->flags = FRAME_MALLOC; } frame->tmp = 0; /* should not preserve tmp */ if (!frame->prev) break; @@ -7781,7 +7783,7 @@ rb_thread_status(thread) rb_thread_t th = rb_thread_check(thread); if (rb_thread_dead(th)) { - if (NIL_P(th->errinfo) && (th->flags & THREAD_RAISED)) + if (!NIL_P(th->errinfo) && (th->flags & THREAD_RAISED)) return Qnil; return Qfalse; } diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index a40b3532b1..a63acec1d8 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -216,6 +216,7 @@ module Net raise FTPReplyError, resp end conn = sock.accept + sock.close end return conn end