# Buggy code
def _GetSerializedDataOffsetTable(
    self, offset_tables_cache, offset_tables_lfu, stream_name_prefix, stream_number
):
    """Retrieves the serialized data offset table.

    Args:
      offset_tables_cache (dict): offset tables cache.
      offset_tables_lfu (list[_SerializedDataOffsetTable]): least frequently
          used (LFU) offset tables.
      stream_name_prefix (str): stream name prefix.
      stream_number (str): number of the stream.

    Returns:
      _SerializedDataOffsetTable: serialized data offset table.

    Raises:
      IOError: if the stream cannot be opened.
    """
    offset_table = offset_tables_cache.get(stream_number, None)
    if not offset_table:
        stream_name = "{0:s}.{1:06d}".format(stream_name_prefix, stream_number)
        if not self._HasStream(stream_name):
            raise IOError("No such stream: {0:s}".format(stream_name))

        offset_table = _SerializedDataOffsetTable(self._zipfile, stream_name)
        offset_table.Read()

        number_of_tables = len(offset_tables_cache)
        if number_of_tables >= self._MAXIMUM_NUMBER_OF_CACHED_TABLES:
            lfu_stream_number = self._event_offset_tables_lfu.pop()
            del offset_tables_cache[lfu_stream_number]

        offset_tables_cache[stream_number] = offset_table

    if stream_number in offset_tables_lfu:
        lfu_index = offset_tables_lfu.index(stream_number)
        offset_tables_lfu.pop(lfu_index)

    offset_tables_lfu.append(stream_number)

    return offset_table


# Traceback (IndexError)
Traceback (most recent call last):
File "/usr/bin/log2timeline.py", line 767, in <module>
if not Main():
File "/usr/bin/log2timeline.py", line 753, in Main
tool.ProcessSources()
File "/usr/bin/log2timeline.py", line 664, in ProcessSources
timezone=self._timezone, yara_rules_string=self._yara_rules_string)
File "/usr/lib/python2.7/dist-packages/plaso/frontend/extraction_frontend.py", line 483, in ProcessSources
yara_rules_string=yara_rules_string)
File "/usr/lib/python2.7/dist-packages/plaso/multi_processing/task_engine.py", line 791, in ProcessSources
filter_find_specs=filter_find_specs)
File "/usr/lib/python2.7/dist-packages/plaso/multi_processing/task_engine.py", line 288, in _ProcessSources
self._ScheduleTasks(storage_writer)
File "/usr/lib/python2.7/dist-packages/plaso/multi_processing/task_engine.py", line 419, in _ScheduleTasks
self._FillEventSourceHeap(storage_writer, event_source_heap)
File "/usr/lib/python2.7/dist-packages/plaso/multi_processing/task_engine.py", line 351, in _FillEventSourceHeap
event_source = storage_writer.GetNextWrittenEventSource()
File "/usr/lib/python2.7/dist-packages/plaso/storage/zip_file.py", line 3175, in GetNextWrittenEventSource
self._written_event_source_index)
File "/usr/lib/python2.7/dist-packages/plaso/storage/zip_file.py", line 2582, in GetEventSourceByIndex
offset_table = self._GetSerializedEventSourceOffsetTable(stream_number)
File "/usr/lib/python2.7/dist-packages/plaso/storage/zip_file.py", line 1443, in _GetSerializedEventSourceOffsetTable
u'event_source_index', stream_number)
File "/usr/lib/python2.7/dist-packages/plaso/storage/zip_file.py", line 1375, in _GetSerializedDataOffsetTable
lfu_stream_number = self._event_offset_tables_lfu.pop()
IndexError: pop from empty list

# Fixed code
def _GetSerializedDataOffsetTable(
    self, offset_tables_cache, offset_tables_lfu, stream_name_prefix, stream_number
):
    """Retrieves the serialized data offset table.

    Args:
      offset_tables_cache (dict): offset tables cache.
      offset_tables_lfu (list[_SerializedDataOffsetTable]): least frequently
          used (LFU) offset tables.
      stream_name_prefix (str): stream name prefix.
      stream_number (int): number of the stream.

    Returns:
      _SerializedDataOffsetTable: serialized data offset table.

    Raises:
      IOError: if the stream cannot be opened.
    """
    offset_table = offset_tables_cache.get(stream_number, None)
    if not offset_table:
        stream_name = "{0:s}.{1:06d}".format(stream_name_prefix, stream_number)
        if not self._HasStream(stream_name):
            raise IOError("No such stream: {0:s}".format(stream_name))

        offset_table = _SerializedDataOffsetTable(self._zipfile, stream_name)
        offset_table.Read()

        number_of_tables = len(offset_tables_cache)
        if number_of_tables >= self._MAXIMUM_NUMBER_OF_CACHED_TABLES:
            lfu_stream_number = offset_tables_lfu.pop()
            del offset_tables_cache[lfu_stream_number]

        offset_tables_cache[stream_number] = offset_table

    if stream_number in offset_tables_lfu:
        lfu_index = offset_tables_lfu.index(stream_number)
        offset_tables_lfu.pop(lfu_index)

    offset_tables_lfu.append(stream_number)

    return offset_table