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:
Tim Peters 2001-09-15 02:35:15 +00:00
parent 1048aa933f
commit 0891ac017d
2 changed files with 27 additions and 0 deletions

View file

@ -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;