mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
The 'p' (Pascal string) pack code acts unreasonably when the string size
and count exceed 255. Changed to preserve as much of the string as possible (instead of count%256 characters).
This commit is contained in:
parent
1048aa933f
commit
0891ac017d
2 changed files with 27 additions and 0 deletions
|
|
@ -1360,6 +1360,8 @@ struct_pack(PyObject *self, PyObject *args)
|
|||
if (n < num)
|
||||
/* no real need, just to be nice */
|
||||
memset(res+1+n, '\0', num-n);
|
||||
if (n > 255)
|
||||
n = 255;
|
||||
*res++ = n; /* store the length byte */
|
||||
res += num;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue