summaryrefslogtreecommitdiff
path: root/simplejson/scanner.py
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2014-06-24 11:49:26 -0700
committerBob Ippolito <bob@redivi.com>2014-06-24 11:49:26 -0700
commitb7486b82233ed2ec1a614dcf8944d376d12d04bf (patch)
treee8c2f1ae3d8544d9453bc2281e631d3a6b68fba7 /simplejson/scanner.py
parenta19d53c1df389648b31619eda67cb178f8f00036 (diff)
downloadsimplejson-b7486b82233ed2ec1a614dcf8944d376d12d04bf.tar.gz
Fix lower bound checking in scan_once / raw_decode API #98v3.5.3
Diffstat (limited to 'simplejson/scanner.py')
-rw-r--r--simplejson/scanner.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/simplejson/scanner.py b/simplejson/scanner.py
index b7918b3..5abed35 100644
--- a/simplejson/scanner.py
+++ b/simplejson/scanner.py
@@ -118,6 +118,11 @@ def py_make_scanner(context):
raise JSONDecodeError(errmsg, string, idx)
def scan_once(string, idx):
+ if idx < 0:
+ # Ensure the same behavior as the C speedup, otherwise
+ # this would work for *some* negative string indices due
+ # to the behavior of __getitem__ for strings. #98
+ raise JSONDecodeError('Expecting value', string, idx)
try:
return _scan_once(string, idx)
finally: