From 4686aba35526fd9cc2ff3113dca09deabd693fb5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Wed, 26 May 2021 20:59:21 +0200
Subject: [PATCH] added extra tests, faster tests

---
 minijson.pyx | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/minijson.pyx b/minijson.pyx
index 4fde182..3408cbf 100644
--- a/minijson.pyx
+++ b/minijson.pyx
@@ -313,7 +313,9 @@ cpdef int dump(object data, cio: io.BytesIO) except -1:
         return 1
     elif isinstance(data, str):
         length = len(data)
-        if length < 128:
+        if length < 0:
+            raise EncodingError('Invalid length!')
+        elif length < 128:
             cio.write(bytearray([0x80 | length]))
             cio.write(data.encode('utf-8'))
             return 1+length
-- 
GitLab