# Buggy code
def ParseFileObject(self, parser_mediator, file_object, **kwargs):
    """Parses a Windows Registry file-like object.

    Args:
      parser_mediator: a parser mediator object (instance of ParserMediator).
      file_object: a file-like object.
    """
    win_registry_reader = FileObjectWinRegistryFileReader()
    registry_file = win_registry_reader.Open(file_object)

    win_registry = dfwinreg_registry.WinRegistry()
    key_path_prefix = win_registry.GetRegistryFileMapping(registry_file)
    registry_file.SetKeyPathPrefix(key_path_prefix)
    root_key = registry_file.GetRootKey()
    if not root_key:
        return

    try:
        for registry_key in root_key.RecurseKeys():
            # TODO: use a filter tree to optimize lookups.
            found_matching_plugin = False
            for plugin_object in self._plugins:
                if parser_mediator.abort:
                    break

                if self._CanProcessKeyWithPlugin(registry_key, plugin_object):
                    found_matching_plugin = True
                    plugin_object.UpdateChainAndProcess(parser_mediator, registry_key)

            if not found_matching_plugin:
                self._default_plugin.UpdateChainAndProcess(
                    parser_mediator, registry_key
                )

    except IOError as exception:
        parser_mediator.ProduceParseError("{0:s}".format(exception))


# Traceback (WinRegistryValueError)
2015-11-27 16:57:21,504 [WARNING] (Worker_01 ) PID:10600 <worker> Unhandled exception while processing path spec: type: OS, location: /home/onager/code/plaso/test_data/SOFTWARE-RunTests
2015-11-27 16:57:21,504 [ERROR] (Worker_01 ) PID:10600 <worker> Unable to read data from value: lParam with error: pyregf_value_get_data_as_integer: unable to retrieve integer value. libregf_value_type_copy_to_32bit: invalid value data size value out of bounds. libregf_value_get_value_32bit: unable to set 32-bit value.
Traceback (most recent call last):
File "/home/onager/code/plaso/plaso/engine/worker.py", line 570, in _ProcessPathSpec
self._ProcessFileEntry(file_entry, data_stream_name=data_stream_name)
File "/home/onager/code/plaso/plaso/engine/worker.py", line 523, in _ProcessFileEntry
self._ProcessDataStream(file_entry, data_stream_name=data_stream_name)
File "/home/onager/code/plaso/plaso/engine/worker.py", line 464, in _ProcessDataStream
parser_object, file_entry, file_object=file_object)
File "/home/onager/code/plaso/plaso/engine/worker.py", line 261, in _ParseFileEntryWithParser
parser_object.Parse(self._parser_mediator, file_object)
File "/home/onager/code/plaso/plaso/parsers/interface.py", line 288, in Parse
self.ParseFileObject(parser_mediator, file_object, **kwargs)
File "/home/onager/code/plaso/plaso/parsers/winreg.py", line 119, in ParseFileObject
parser_mediator, registry_key)
File "/home/onager/code/plaso/plaso/parsers/winreg_plugins/interface.py", line 280, in UpdateChainAndProcess
self.Process(parser_mediator, registry_key, **kwargs)
File "/home/onager/code/plaso/plaso/parsers/winreg_plugins/interface.py", line 265, in Process
self.GetEntries(parser_mediator, registry_key, **kwargs)
File "/home/onager/code/plaso/plaso/parsers/winreg_plugins/default.py", line 50, in GetEntries
registry_value.data_type_string, registry_value.GetData())
File "/home/onager/code/plaso/plaso/dfwinreg/regf.py", line 175, in GetData
self._pyregf_value.name, exception))
WinRegistryValueError: Unable to read data from value: lParam with error: pyregf_value_get_data_as_integer: unable to retrieve integer value. libregf_value_type_copy_to_32bit: invalid value data size value out of bounds. libregf_value_get_value_32bit: unable to set 32-bit value.

# Fixed code
def ParseFileObject(self, parser_mediator, file_object, **kwargs):
    """Parses a Windows Registry file-like object.

    Args:
      parser_mediator: a parser mediator object (instance of ParserMediator).
      file_object: a file-like object.
    """
    win_registry_reader = FileObjectWinRegistryFileReader()
    registry_file = win_registry_reader.Open(file_object)

    win_registry = dfwinreg_registry.WinRegistry()
    key_path_prefix = win_registry.GetRegistryFileMapping(registry_file)
    registry_file.SetKeyPathPrefix(key_path_prefix)
    root_key = registry_file.GetRootKey()
    if not root_key:
        return

    try:
        self._ParseRecurseKeys(parser_mediator, root_key)
    except IOError as exception:
        parser_mediator.ProduceParseError("{0:s}".format(exception))