summaryrefslogtreecommitdiffstats
path: root/Modules/structmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-01-03 15:40:33 (GMT)
committerGuido van Rossum <guido@python.org>1997-01-03 15:40:33 (GMT)
commitb9d338cbfbca06d60c7a5b31ee5e229fe6b801a2 (patch)
tree3b3a17d6fc66baf9bb89a91064febdb8324588f2 /Modules/structmodule.c
parentdbadd558b5de96ecff74218d44e15515a635b785 (diff)
downloadcpython-b9d338cbfbca06d60c7a5b31ee5e229fe6b801a2.zip
cpython-b9d338cbfbca06d60c7a5b31ee5e229fe6b801a2.tar.gz
cpython-b9d338cbfbca06d60c7a5b31ee5e229fe6b801a2.tar.bz2
Fill pad bytes with zeros (fixing a bug dating from the very first version!).
Diffstat (limited to 'Modules/structmodule.c')
-rw-r--r--Modules/structmodule.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/structmodule.c b/Modules/structmodule.c
index 113e3c5..a42f639 100644
--- a/Modules/structmodule.c
+++ b/Modules/structmodule.c
@@ -1148,7 +1148,7 @@ struct_pack(self, args)
char *fmt;
int size, num;
int i, n;
- char *s, *res, *restart;
+ char *s, *res, *restart, *nres;
char c;
if (args == NULL || !PyTuple_Check(args) ||
@@ -1186,7 +1186,10 @@ struct_pack(self, args)
e = getentry(c, f);
if (e == NULL)
goto fail;
- res = restart + align((int)(res-restart), c, e);
+ nres = restart + align((int)(res-restart), c, e);
+ /* Fill padd bytes with zeros */
+ while (res < nres)
+ *res++ = '\0';
if (num == 0 && c != 's')
continue;
do {