Skip to content

Commit

Permalink
Uninitialized vars when not parsing a Dsc file
Browse files Browse the repository at this point in the history
  • Loading branch information
Schramp committed Nov 9, 2023
1 parent 13a3546 commit 8817959
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions UnifiedLog/dsc_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ def __init__(self, v_file):
self._format_version = None
self.uuid_entries = [] # [ [v_off, size, uuid, lib_path, lib_name], [..], ..] # v_off is virt offset
self.uuid_entry_dict = {}
self.uuid_entry_offsets = []
self.num_uuid_entries = 0
self.range_entries = {} # {v_off: [uuid_index, v_off, data_offset, data_len]} # data_offset is absolute in file
self.range_entry_offsets = []
self.num_range_entries = 0
self.fmt_cache = {}

Expand Down Expand Up @@ -144,15 +146,16 @@ def FindVirtualOffsetEntries(self, v_offset):
pos=bisect_right(self.range_entry_offsets, v_offset, 0, self.num_range_entries)
# now, the v_offset is somewhere *after* the previous range, so we need
# to check if the v_offsets falls within the *previous* range
range_offset = self.range_entry_offsets[pos-1]
# get the range
a = self.range_entries[range_offset]
if pos > 0:
range_offset = self.range_entry_offsets[pos-1]
# get the range
a = self.range_entries[range_offset]

# now check if the v_offset is within the range
if (a[1] + a[3]) > v_offset:
ret_range_entry = a
ret_uuid_entry = self.uuid_entries[a[0]]
return (ret_range_entry, ret_uuid_entry)
# now check if the v_offset is within the range
if (a[1] + a[3]) > v_offset:
ret_range_entry = a
ret_uuid_entry = self.uuid_entries[a[0]]
return (ret_range_entry, ret_uuid_entry)

#Not found
logger.error('Failed to find v_offset in Dsc!')
Expand Down Expand Up @@ -202,13 +205,14 @@ def GetUuidEntryFromVirtualOffset(self, v_offset):
pos=bisect_right(self.uuid_entry_offsets, v_offset, 0, self.num_uuid_entries)
# now, the v_offset is somewhere *after* the previous range, so we need
# to check if the v_offsets falls within the *previous* range
uuid_offset = self.uuid_entry_offsets[pos-1]
# get the range
b = self.uuid_entry_dict[uuid_offset]

# now check if the v_offset is within the uuid range
if (b[0] + b[1]) > v_offset:
return b
if pos > 0:
uuid_offset = self.uuid_entry_offsets[pos-1]
# get the range
b = self.uuid_entry_dict[uuid_offset]

# now check if the v_offset is within the uuid range
if (b[0] + b[1]) > v_offset:
return b

logger.error('Failed to find uuid_entry for v_offset 0x{:X} in Dsc!'.format(v_offset))
return None
Expand Down

0 comments on commit 8817959

Please sign in to comment.