aboutsummaryrefslogtreecommitdiffstats
path: root/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'time.c')
-rw-r--r--time.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/time.c b/time.c
index 8b3ac6c501..455f15bc1f 100644
--- a/time.c
+++ b/time.c
@@ -12,6 +12,7 @@
#include "ruby/ruby.h"
#include <sys/types.h>
#include <time.h>
+#include "ruby/encoding.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -2077,6 +2078,9 @@ time_strftime(VALUE time, VALUE format)
time_get_tm(time, tobj->gmt);
}
StringValue(format);
+ if (!rb_enc_str_asciicompat_p(format)) {
+ rb_raise(rb_eArgError, "format should have ASCII compatible encoding");
+ }
format = rb_str_new4(format);
fmt = RSTRING_PTR(format);
len = RSTRING_LEN(format);