diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-09-15 02:35:15 +0000 |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-09-15 02:35:15 +0000 |
commit | 1ab395f44b18b11135ccbfc13a2cf1c7ad462471 (patch) | |
tree | 2854fbee383d936465f78207fec7243790657ae4 /Modules/structmodule.c | |
parent | 6fabbcf031a9f91edb0c8fb72a294fb3b3f7c2c5 (diff) | |
download | cpython-1ab395f44b18b11135ccbfc13a2cf1c7ad462471.tar.gz |
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).
Diffstat (limited to 'Modules/structmodule.c')
-rw-r--r-- | Modules/structmodule.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Modules/structmodule.c b/Modules/structmodule.c index 46aa75bd53..61436f92a8 100644 --- a/Modules/structmodule.c +++ b/Modules/structmodule.c @@ -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; |