summaryrefslogtreecommitdiff
path: root/core/gdbm/gdbm-1.8.3-zeroheaders.patch
blob: 088956aef3bb749767e333ddbbfd5636fc267b4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
02_zero-headers.patch by Jeff Johnson <jbj@redhat.com> and Colin Watson <cjwatson@debian.org>

diff -urNad a/falloc.c b/falloc.c
--- a/falloc.c	2001-02-28 06:52:33.000000000 +0000
+++ b/falloc.c	2003-09-08 23:58:43.000000000 +0100
@@ -272,7 +272,7 @@
 
 
   /* Split the header block. */
-  temp = (avail_block *) malloc (av_size);
+  temp = (avail_block *) calloc (1, av_size);
   if (temp == NULL) _gdbm_fatal (dbf, "malloc error");
   /* Set the size to be correct AFTER the pop_avail_block. */
   temp->size = dbf->header->avail.size;
diff -urNad a/gdbmopen.c b/gdbmopen.c
--- a/gdbmopen.c	2003-09-08 23:58:01.000000000 +0100
+++ b/gdbmopen.c	2003-09-08 23:58:43.000000000 +0100
@@ -212,7 +212,7 @@
 	file_block_size = block_size;
 
       /* Get space for the file header. */
-      dbf->header = (gdbm_file_header *) malloc (file_block_size);
+      dbf->header = (gdbm_file_header *) calloc (1, file_block_size);
       if (dbf->header == NULL)
 	{
 	  gdbm_close (dbf);
@@ -256,7 +256,7 @@
 	(dbf->header->block_size - sizeof (hash_bucket))
 	/ sizeof (bucket_element) + 1;
       dbf->header->bucket_size  = dbf->header->block_size;
-      dbf->bucket = (hash_bucket *) malloc (dbf->header->bucket_size);
+      dbf->bucket = (hash_bucket *) calloc (1, dbf->header->bucket_size);
       if (dbf->bucket == NULL)
 	{
 	  gdbm_close (dbf);
@@ -420,7 +420,7 @@
       for(index = 0; index < size; index++)
         {
           (dbf->bucket_cache[index]).ca_bucket
-            = (hash_bucket *) malloc (dbf->header->bucket_size);
+            = (hash_bucket *) calloc (1, dbf->header->bucket_size);
           if ((dbf->bucket_cache[index]).ca_bucket == NULL)
 	    {
               gdbm_errno = GDBM_MALLOC_ERROR;