]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fill pad bytes with zeros (fixing a bug dating from the very first version!).
authorGuido van Rossum <guido@python.org>
Fri, 3 Jan 1997 15:40:33 +0000 (15:40 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 3 Jan 1997 15:40:33 +0000 (15:40 +0000)
Modules/structmodule.c

index 113e3c507b3ec17c4ed7992c43d06f1d48d8f361..a42f639e67bbd97842be9eaee65e674e3a5edca1 100644 (file)
@@ -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 {