From 13424f32fe761c8b10bd86ac8ebc2d88a21da268 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 3 Dec 2008 05:48:55 +0000 Subject: [PATCH] * ext/tk/tcltklib.c (ip_ruby_cmd, ip_invoke_with_position): must not access internal union directly. [ruby-list:45670] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/tk/tcltklib.c | 20 +++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80f2edcb43..4949ed4d14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 3 14:48:52 2008 Nobuyoshi Nakada + + * ext/tk/tcltklib.c (ip_ruby_cmd, ip_invoke_with_position): must + not access internal union directly. [ruby-list:45670] + Wed Dec 3 12:24:08 2008 Nobuyoshi Nakada * io.c (rb_io_getc, rb_io_readchar): documentation correction from diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c index 34b66f76e6..dadab2f221 100644 --- a/ext/tk/tcltklib.c +++ b/ext/tk/tcltklib.c @@ -3090,21 +3090,19 @@ ip_ruby_cmd(clientData, interp, argc, argv) /* get args */ args = rb_ary_new2(argc - 2); for(i = 3; i < argc; i++) { + VALUE s; #if TCL_MAJOR_VERSION >= 8 str = Tcl_GetStringFromObj(argv[i], &len); + s = rb_tainted_str_new(str, len); +#else /* TCL_MAJOR_VERSION < 8 */ + str = argv[i]; + s = rb_tainted_str_new2(str); +#endif DUMP2("arg:%s",str); #ifndef HAVE_STRUCT_RARRAY_LEN - rb_ary_push(args, rb_tainted_str_new(str, len)); + rb_ary_push(args, s); #else - RARRAY(args)->as.heap.ptr[RARRAY(args)->as.heap.len++] = rb_tainted_str_new(str, len); -#endif -#else /* TCL_MAJOR_VERSION < 8 */ - DUMP2("arg:%s",argv[i]); -#ifndef HAVE_STRUCT_RARRAY_LEN - rb_ary_push(args, rb_tainted_str_new2(argv[i])); -#else - RARRAY(args)->as.heap.ptr[RARRAY(args)->as.heap.len++] = rb_tainted_str_new2(argv[i]); -#endif + RARRAY(args)->ptr[RARRAY(args)->len++] = s; #endif } @@ -8295,7 +8293,7 @@ ip_invoke_with_position(argc, argv, obj, position) DUMP2("back from handler (current thread:%lx)", current); /* get result & free allocated memory */ - ret = RARRAY(result)->as.heap.ptr[0]; + ret = RARRAY_PTR(result)[0]; #if 0 /* use Tcl_EventuallyFree */ Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */ #else