--- a/trunk/src/charset.c
+++ b/trunk/src/charset.c
@@ -150,7 +150,7 @@
 	if (out_len == 0) return NULL;
 
 	if (*in == special_char){
-	    if (length >= 2) return NULL;
+	    if (length < 2) return NULL;
 	    string++; length--;
 	    strbuf[len++] = *string;
 	    string++; length--;