summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-13 09:41:22 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-13 09:41:22 (GMT)
commit23b4c10dd8dcde2b955072ef0f014bb291866e89 (patch)
tree409c0ab5297eb4291302655bc5354d30ddddd64b /sprintf.c
parent6b1bae96414470aba86b8ba7a5822d7d634da8d9 (diff)
* sprintf.c (rb_enc_vsprintf): can be used for ASCII compatible
encodings only. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sprintf.c b/sprintf.c
index eb8cd73..bae6c14 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -1168,7 +1168,13 @@ rb_enc_vsprintf(rb_encoding *enc, const char *fmt, va_list ap)
f._bf._size = 0;
f._w = 120;
result = rb_str_buf_new(f._w);
- if (enc) rb_enc_associate(result, enc);
+ if (enc) {
+ if (!rb_enc_asciicompat(enc)) {
+ rb_raise(rb_eArgError, "cannot construct ASCII-incompatible encoding string: %s",
+ rb_enc_name(enc));
+ }
+ rb_enc_associate(result, enc);
+ }
f._bf._base = (unsigned char *)result;
f._p = (unsigned char *)RSTRING_PTR(result);
RBASIC(result)->klass = 0;