summaryrefslogtreecommitdiff
path: root/ext/io
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-15 00:02:41 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-15 00:02:41 +0000
commit0177687124be88f9fc0981d737bbdb7c57cb971f (patch)
tree517e7c0075a0e05b9809eb686d0448fde3aafe7e /ext/io
parent336ab28593360d107f2789d0e54d5029d9d01b7f (diff)
io/console: reject symbols with nul char
* ext/io/console/console.c (console_key_pressed_p): symbol names can contain nul chars, reject them. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/io')
-rw-r--r--ext/io/console/console.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index fd3f03b..17fee11 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -718,13 +718,12 @@ console_key_pressed_p(VALUE io, VALUE k)
}
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);
}