/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/annotate.py

  • Committer: John Arbash Meinel
  • Date: 2009-12-14 15:52:24 UTC
  • mto: (4634.107.1 2.0)
  • mto: This revision was merged to the branch mainline in revision 4897.
  • Revision ID: john@arbash-meinel.com-20091214155224-6av92htxukvp69jk
Fix a rare segmentation fault in the groupcompress code.

When finding the location to insert an entry in the hash map,
we start by going to the next hash bucket, and walking backwards
to find the last empty entry.
The last entry in the hash table intentionally points to just
after the actual entry table, so that we have an 'upper bound'.
However, if the last actual bucket was full, this could cause
us to check to see if the 'sentinal' value pointed to NULL,
which isn't valid. If the memory allocator did not allocate
extra bytes after then end of the entry table, this would
access invalid memory and segfault.
The fix is to change the if check to evaluate whether the current
pointer is in the current bucket before we check to see whether
it is empty. (Note that the double check *should* be redundant.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
458
458
 
459
459
try:
460
460
    from bzrlib._annotator_pyx import Annotator
461
 
except ImportError, e:
462
 
    osutils.failed_to_load_extension(e)
 
461
except ImportError:
463
462
    from bzrlib._annotator_py import Annotator