[前][次][番号順一覧][スレッド一覧]

ruby-changes:42511

From: nobu <ko1@a...>
Date: Fri, 15 Apr 2016 08:06:06 +0900 (JST)
Subject: [ruby-changes:42511] nobu:r54584 (trunk): io/console: reject symbols with nul char

nobu	2016-04-15 09:02:41 +0900 (Fri, 15 Apr 2016)

  New Revision: 54584

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54584

  Log:
    io/console: reject symbols with nul char
    
    * ext/io/console/console.c (console_key_pressed_p): symbol names
      can contain nul chars, reject them.

  Modified files:
    trunk/ext/io/console/console.c
Index: ext/io/console/console.c
===================================================================
--- ext/io/console/console.c	(revision 54583)
+++ ext/io/console/console.c	(revision 54584)
@@ -718,13 +718,12 @@ console_key_pressed_p(VALUE io, VALUE k) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L718
     }
     else {
 	const struct vktable *t;
+	const char *kn;
 	if (SYMBOL_P(k)) {
 	    k = rb_sym2str(k);
 	}
-	else {
-	    StringValueCStr(k);
-	}
-	t = console_win32_vk(RSTRING_PTR(k), RSTRING_LEN(k));
+	kn = StringValueCStr(k);
+	t = console_win32_vk(kn, RSTRING_LEN(k));
 	if (!t || (vk = (short)t->vk) == -1) {
 	    rb_raise(rb_eArgError, "unknown virtual key code: %"PRIsVALUE, k);
 	}

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]