/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/hooks.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:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
"""Support for plugin hooking logic."""
19
19
from bzrlib import registry
20
20
from bzrlib.lazy_import import lazy_import
 
21
from bzrlib.symbol_versioning import deprecated_method
21
22
lazy_import(globals(), """
22
23
import textwrap
23
24
 
44
45
    'bzrlib.info', 'InfoHooks')
45
46
known_hooks.register_lazy(('bzrlib.lock', 'Lock.hooks'), 'bzrlib.lock',
46
47
    'LockHooks')
47
 
known_hooks.register_lazy(('bzrlib.merge', 'Merger.hooks'), 'bzrlib.merge',
48
 
    'MergeHooks')
49
48
known_hooks.register_lazy(('bzrlib.msgeditor', 'hooks'), 'bzrlib.msgeditor',
50
49
    'MessageEditorHooks')
51
50
known_hooks.register_lazy(('bzrlib.mutabletree', 'MutableTree.hooks'),
58
57
    ('bzrlib.version_info_formats.format_rio', 'RioVersionInfoBuilder.hooks'),
59
58
    'bzrlib.version_info_formats.format_rio', 'RioVersionInfoBuilderHooks')
60
59
known_hooks.register_lazy(
61
 
    ('bzrlib.merge_directive', 'BaseMergeDirective.hooks'),
 
60
    ('bzrlib.merge_directive', '_BaseMergeDirective.hooks'),
62
61
    'bzrlib.merge_directive', 'MergeDirectiveHooks')
63
62
 
64
63
 
278
277
 
279
278
See `Using hooks`_ in the User Guide for examples.
280
279
 
281
 
.. _Using hooks: ../user-guide/hooks.html
 
280
.. _Using hooks: ../user-guide/index.html#using-hooks
282
281
 
283
282
The class that contains each hook is given before the hooks it supplies. For
284
283
instance, BranchHooks as the class is the hooks class for