New upstream version of cairo - 1.8.0 - fixes crash.
[fedora-mingw.git] / gdbm / gdbm-1.8.0-64offset.patch
1 diff -buNr gdbm-1.8.0.orig/falloc.c gdbm-1.8.0/falloc.c
2 --- gdbm-1.8.0.orig/falloc.c    Tue May 18 20:16:06 1999
3 +++ gdbm-1.8.0/falloc.c Thu Apr 25 18:20:45 2002
4 @@ -180,6 +180,13 @@
5    avail_block *new_blk;
6    int index;
7  
8 +  if (dbf->header->avail.count == dbf->header->avail.size)
9 +    {
10 +      /* We're kind of stuck here, so we re-split the header in order to
11 +         avoid crashing.  Sigh. */
12 +      push_avail_block(dbf);
13 +    }
14 +
15    /* Set up variables. */
16    new_el.av_adr = dbf->header->avail.next_block;
17    new_el.av_size = ( ( (dbf->header->avail.size * sizeof (avail_elem)) >> 1)
18 @@ -196,12 +203,24 @@
19    if (num_bytes != new_el.av_size) _gdbm_fatal (dbf, "read error");
20  
21    /* Add the elements from the new block to the header. */
22 -  for (index = 0; index < new_blk->count; index++)
23 +  index = 0;
24 +  while (index < new_blk->count)
25 +    {
26 +      while(index < new_blk->count
27 +            && dbf->header->avail.count < dbf->header->avail.size)
28      {
29        /* With luck, this will merge a lot of blocks! */
30        _gdbm_put_av_elem(new_blk->av_table[index],
31                         dbf->header->avail.av_table,
32 -                       &dbf->header->avail.count, dbf->coalesce_blocks);
33 +                            &dbf->header->avail.count, TRUE);
34 +          index++;
35 +       }
36 +      if (dbf->header->avail.count == dbf->header->avail.size)
37 +        {
38 +          /* We're kind of stuck here, so we re-split the header in order to
39 +             avoid crashing.  Sigh. */
40 +          push_avail_block(dbf);
41 +       }
42      }
43  
44    /* Fix next_block, as well. */
45 @@ -210,9 +229,17 @@
46    /* We changed the header. */
47    dbf->header_changed = TRUE;
48  
49 -  /* Free the previous avail block. */
50 +  /* Free the previous avail block.   It is possible that the header table
51 +     is now FULL, which will cause us to overflow it! */
52 +  if (dbf->header->avail.count == dbf->header->avail.size)
53 +    {
54 +      /* We're kind of stuck here, so we re-split the header in order to
55 +         avoid crashing.  Sigh. */
56 +      push_avail_block(dbf);
57 +    }
58 +
59    _gdbm_put_av_elem (new_el, dbf->header->avail.av_table,
60 -                    &dbf->header->avail.count, dbf->coalesce_blocks);
61 +                    &dbf->header->avail.count, TRUE);
62    free (new_blk);
63  }
64