Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion gprof2dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,15 @@ def parse_cost_line(self, calls=None):
if not mo:
return False

values = line.split()

# Costs are non-negative integer event counts. Position columns may
# be relative (signed) or hexadecimal, but cost columns may not, so a
# line that smuggles such a token into a cost column is malformed and
# must not be allowed to skew the totals.
if not all(value.isdigit() for value in values[self.num_positions:]):
return False

function = self.get_function()

if calls is None:
Expand All @@ -1802,7 +1811,6 @@ def parse_cost_line(self, calls=None):
except KeyError:
pass

values = line.split()
assert len(values) <= self.num_positions + self.num_events

positions = values[0 : self.num_positions]
Expand Down Expand Up @@ -1851,6 +1859,10 @@ def parse_association_spec(self):

_, values = line.split('=', 1)
values = values.strip().split()
# The call count is a non-negative integer; reject a malformed or
# negative count rather than letting it through as a bogus tally.
if not values or not values[0].isdigit():
return False
calls = int(values[0])
call_position = values[1:]
self.consume()
Expand Down
Loading