summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-04-12 03:39:50 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-04-12 03:39:50 +0000
commitb346101b25b6678d89503e152366eae5b85c92e0 (patch)
treefe2b181a7eb396bfa09c836fbdb2e00062972f91
parentf5af2022620d823dfd7390298679434450115bd0 (diff)
downloadruby-b346101b25b6678d89503e152366eae5b85c92e0.tar.gz
* ext/tk/tcltklib.c (ip_finalize): fix SEGV when Tcl_GlobalEval()
modifies the argument string to eval. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/tk/tcltklib.c24
2 files changed, 20 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index d43b8875e1..001d603b3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Apr 12 12:38:06 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/tcltklib.c (ip_finalize): fix SEGV when Tcl_GlobalEval()
+ modifies the argument string to eval.
+
Tue Apr 12 02:21:55 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/tcltklib.c (ip_finalize): add existence check of
diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c
index f744df9409..f598ed4a0d 100644
--- a/ext/tk/tcltklib.c
+++ b/ext/tk/tcltklib.c
@@ -4,7 +4,7 @@
* Oct. 24, 1997 Y. Matsumoto
*/
-#define TCLTKLIB_RELEASE_DATE "2005-03-30"
+#define TCLTKLIB_RELEASE_DATE "2005-04-12"
#include "ruby.h"
#include "rubysig.h"
@@ -4408,10 +4408,9 @@ ip_finalize(ip)
/* delete root widget */
DUMP1("check `destroy'");
- if ( Tcl_GetCommandInfo(ip, "catch", &info)
- && Tcl_GetCommandInfo(ip, "destroy", &info) ) {
+ if (Tcl_GetCommandInfo(ip, "destroy", &info)) {
DUMP1("call `destroy'");
- Tcl_GlobalEval(ip, "catch {destroy .}");
+ Tcl_GlobalEval(ip, "destroy .");
}
/* call finalize-hook-proc */
@@ -4422,14 +4421,21 @@ ip_finalize(ip)
}
DUMP1("cancel after callbacks");
+#define AFTER_CANCEL_CMD "foreach id [after info] {after cancel $id}"
DUMP1("check `foreach' & `after'");
- if ( Tcl_GetCommandInfo(ip, "catch", &info)
- && Tcl_GetCommandInfo(ip, "foreach", &info)
+ if ( Tcl_GetCommandInfo(ip, "foreach", &info)
&& Tcl_GetCommandInfo(ip, "after", &info) ) {
- DUMP1("call `foreach' & `after'");
- Tcl_GlobalEval(ip,
- "catch {foreach id [after info] {after cancel $id}}");
+ char *cmd;
+ if ((cmd = Tcl_Alloc(strlen(AFTER_CANCEL_CMD) + 1)) == (char*)NULL) {
+ DUMP1("cancel after callbacks : cannot allocate memory");
+ } else {
+ DUMP1("call `foreach' & `after'");
+ strcpy(cmd, AFTER_CANCEL_CMD);
+ Tcl_GlobalEval(ip, cmd);
+ Tcl_Free(cmd);
+ }
}
+#undef AFTER_CANCEL_CMD
Tcl_Release(ip);