diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2008-08-24 23:50:08 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2008-08-24 23:50:08 (GMT) |
commit | 6ae2eb268d55854eafe36fa707ffed980a277d06 (patch) | |
tree | a04d6bc17d7417b5544c85464d68144d40030b42 /Modules/_pickle.c | |
parent | 6e0e0e6749f4e68a9a2d13c4935d1e39546c8114 (diff) | |
download | cpython-6ae2eb268d55854eafe36fa707ffed980a277d06.zip cpython-6ae2eb268d55854eafe36fa707ffed980a277d06.tar.gz cpython-6ae2eb268d55854eafe36fa707ffed980a277d06.tar.bz2 |
Issue #3657: Fix uninitialized memory read when pickling longs.
The conversion to the unicode API was incorrect, it should use bytes.
repr is a bad variable name. The use is overloaded, but I'll leave
that to fix later.
R=Brett
TESTED=./python -E -tt ./Lib/test/regrtest.py -uall
valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \
./python -E -tt ./Lib/test/regrtest.py test_pickletools
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r-- | Modules/_pickle.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 52fa156..ea5bbe2 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -924,10 +924,10 @@ save_long(PicklerObject *self, PyObject *obj) "long too large to pickle"); goto error; } - repr = PyUnicode_FromStringAndSize(NULL, (int)nbytes); + repr = PyBytes_FromStringAndSize(NULL, (Py_ssize_t)nbytes); if (repr == NULL) goto error; - pdata = (unsigned char *)_PyUnicode_AsString(repr); + pdata = (unsigned char *)PyBytes_AS_STRING(repr); i = _PyLong_AsByteArray((PyLongObject *)obj, pdata, nbytes, 1 /* little endian */ , 1 /* signed */ ); |