From: Guido van Rossum Date: Fri, 3 Jan 1997 15:40:33 +0000 (+0000) Subject: Fill pad bytes with zeros (fixing a bug dating from the very first version!). X-Git-Tag: v1.5a1~609 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b9d338cbfbca06d60c7a5b31ee5e229fe6b801a2;p=thirdparty%2FPython%2Fcpython.git Fill pad bytes with zeros (fixing a bug dating from the very first version!). --- diff --git a/Modules/structmodule.c b/Modules/structmodule.c index 113e3c507b3e..a42f639e67bb 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 {