summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/encoding.c b/encoding.c
index cfa49a5122..ee0fdadb39 100644
--- a/encoding.c
+++ b/encoding.c
@@ -662,7 +662,10 @@ rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
int rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc)
{
- int r = rb_enc_precise_mbclen(p, e, enc);
+ int r;
+ if (e <= p)
+ rb_raise(rb_eArgError, "empty string");
+ r = rb_enc_precise_mbclen(p, e, enc);
if (MBCLEN_CHARFOUND(r))
return ONIGENC_MBC_TO_CODE(enc,(UChar*)p,(UChar*)e);
else