]> granicus.if.org Git - python/commitdiff
Avoid using calloc(). This triggered an obscure bug on multiprocessor
authorGuido van Rossum <guido@python.org>
Thu, 16 Jul 1998 15:06:13 +0000 (15:06 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 16 Jul 1998 15:06:13 +0000 (15:06 +0000)
Sparc Solaris 2.6 (fully patched!) that I don't want to dig into, but
which I suspect is a bug in the multithreaded malloc library that only
shows up when run on a multiprocessor.  (The program wasn't using
threads, it was just using the multithreaded C library.)

Objects/dictobject.c

index 7fed379ef59570e0bc524d0a57269ab62081536b..7b6225865b718dc7e33d78cb5146f6398dbd143d 100644 (file)
@@ -283,11 +283,12 @@ dictresize(mp, minused)
                        break;
                }
        }
-       newtable = (dictentry *) calloc(sizeof(dictentry), newsize);
+       newtable = (dictentry *) malloc(sizeof(dictentry) * newsize);
        if (newtable == NULL) {
                PyErr_NoMemory();
                return -1;
        }
+       memset(newtable, '\0', sizeof(dictentry) * newsize);
        mp->ma_size = newsize;
        mp->ma_poly = newpoly;
        mp->ma_table = newtable;