summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-04-15 19:51:09 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-04-15 19:51:09 (GMT)
commit3034efdd298ad5f94a61f9f0e8ab0fee1d2d212e (patch)
tree42236d2d7518cd4f214de096919718811e7ad3fa /Modules
parented3cd7e445e7be413d1b454471454f7ff9f21f1f (diff)
downloadcpython-3034efdd298ad5f94a61f9f0e8ab0fee1d2d212e.zip
cpython-3034efdd298ad5f94a61f9f0e8ab0fee1d2d212e.tar.gz
cpython-3034efdd298ad5f94a61f9f0e8ab0fee1d2d212e.tar.bz2
Issue #17710: Fix pickle raising a SystemError on bogus input.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_pickle.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index d0cebd0..5564803 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -4171,7 +4171,7 @@ load_string(UnpicklerObject *self)
if ((len = _Unpickler_Readline(self, &s)) < 0)
return -1;
- if (len < 3)
+ if (len < 2)
return bad_readline();
if ((s = strdup(s)) == NULL) {
PyErr_NoMemory();
@@ -4179,14 +4179,14 @@ load_string(UnpicklerObject *self)
}
/* Strip outermost quotes */
- while (s[len - 1] <= ' ')
+ while (len > 0 && s[len - 1] <= ' ')
len--;
- if (s[0] == '"' && s[len - 1] == '"') {
+ if (len > 1 && s[0] == '"' && s[len - 1] == '"') {
s[len - 1] = '\0';
p = s + 1;
len -= 2;
}
- else if (s[0] == '\'' && s[len - 1] == '\'') {
+ else if (len > 1 && s[0] == '\'' && s[len - 1] == '\'') {
s[len - 1] = '\0';
p = s + 1;
len -= 2;