Skip to content

Commit 5241e2a

Browse files
Peter Oberparleiteroberpar
authored andcommitted
lcov: fix bug when converting function data in --diff operation
When a patch is applied to a tracefile using command line option --diff and the patch changes the list of functions, the operation aborts with the following error: lcov: Use of freed value in iteration at lcov line 3718. Fix by applying missing calls to keys() when iterating function data hashes. Reported by [email protected].
1 parent 9ce8d8c commit 5241e2a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bin/lcov

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ use Cwd qw /abs_path getcwd/;
7171

7272

7373
# Global constants
74-
our $lcov_version = 'LCOV version 1.11 pre (CVS $Revision: 1.94 $)';
74+
our $lcov_version = 'LCOV version 1.11 pre (CVS $Revision: 1.95 $)';
7575
our $lcov_url = "http://ltp.sourceforge.net/coverage/lcov.php";
7676
our $tool_name = basename($0);
7777

@@ -3711,18 +3711,18 @@ sub adjust_fncdata($$$)
37113711

37123712
# Remove count data in testfncdata for functions which are no longer
37133713
# in funcdata
3714-
foreach $testname (%{$testfncdata}) {
3714+
foreach $testname (keys(%{$testfncdata})) {
37153715
my $fnccount = $testfncdata->{$testname};
37163716

3717-
foreach $func (%{$fnccount}) {
3717+
foreach $func (keys(%{$fnccount})) {
37183718
if (!defined($funcdata->{$func})) {
37193719
delete($fnccount->{$func});
37203720
}
37213721
}
37223722
}
37233723
# Remove count data in sumfnccount for functions which are no longer
37243724
# in funcdata
3725-
foreach $func (%{$sumfnccount}) {
3725+
foreach $func (keys(%{$sumfnccount})) {
37263726
if (!defined($funcdata->{$func})) {
37273727
delete($sumfnccount->{$func});
37283728
}

0 commit comments

Comments
 (0)