@@ -6513,6 +6513,13 @@ sub _read_info
6513
6513
6514
6514
/ ^DA:(\d +),([^,]+)(,([^,\s ]+))?/ && do {
6515
6515
my ($line , $count , $checksum ) = ($1 , $2 , $4 );
6516
+ if ($line <= 0) {
6517
+ lcovutil::ignorable_error(
6518
+ $lcovutil::ERROR_INCONSISTENT_DATA ,
6519
+ " \" $tracefile \" :$. : unexpected line number '$line ' in .info file record '$_ '"
6520
+ );
6521
+ last ;
6522
+ }
6516
6523
if ($readSourceCallback -> notEmpty()) {
6517
6524
# does the source checksum match the recorded checksum?
6518
6525
if ($verify_checksum ) {
@@ -6567,6 +6574,13 @@ sub _read_info
6567
6574
my $lineNo = $1 ;
6568
6575
my $fnName = $4 ;
6569
6576
my $end_line = $3 ;
6577
+ if ($lineNo <= 0) {
6578
+ lcovutil::ignorable_error(
6579
+ $lcovutil::ERROR_INCONSISTENT_DATA ,
6580
+ " \" $tracefile \" :$. : unexpected line number '$lineNo ' in .info file record '$_ '"
6581
+ );
6582
+ last ;
6583
+ }
6570
6584
# the function may already be defined by another testcase
6571
6585
# (for the same file)
6572
6586
$functionMap -> define_function($fnName , $filename , $lineNo ,
@@ -6597,6 +6611,24 @@ sub _read_info
6597
6611
my ($line , $is_exception , $block , $d ) =
6598
6612
($1 , defined ($2 ) && ' e' eq $2 , $3 , $4 );
6599
6613
6614
+ if ($line <= 0) {
6615
+ # Python coverage.py emits line number 0 (zero) for branches
6616
+ # - which is bogus, as there is no line number zero,
6617
+ # and the corresponding branch expression is not there in
6618
+ # any case.
6619
+ # Meantime: this confuses the lcov DB - so we simply skip
6620
+ # such data.
6621
+ # Note that we only need to check while reading .info files.
6622
+ # - if we wrote one from geninfo, then we will not have
6623
+ # produced bogus data - so no need to check.
6624
+ # - only some (broken) external tool could have the issue
6625
+ lcovutil::ignorable_error(
6626
+ $lcovutil::ERROR_INCONSISTENT_DATA ,
6627
+ " \" $tracefile \" :$. : unexpected line number '$line ' in .info file record '$_ '"
6628
+ );
6629
+ last ;
6630
+ }
6631
+
6600
6632
last if $is_exception && $lcovutil::exclude_exception_branch ;
6601
6633
my $comma = rindex ($d , ' ,' );
6602
6634
my $taken = substr ($d , $comma + 1);
@@ -6866,15 +6898,24 @@ sub write_info($$$)
6866
6898
defined ($data -> end_line()) ?
6867
6899
' ,' . $data -> end_line() :
6868
6900
' ' ;
6901
+ if ($line <= 0) {
6902
+ my $alias = (sort keys %$aliases )[0];
6903
+ lcovutil::ignorable_error(
6904
+ $lcovutil::ERROR_INCONSISTENT_DATA ,
6905
+ " \" $source_file \" : unexpected line number '$line ' for function $alias "
6906
+ );
6907
+ next ;
6908
+ }
6869
6909
foreach my $alias (sort keys %$aliases ) {
6870
6910
print (INFO_HANDLE " FN:$line$endLine ,$alias \n " );
6871
6911
}
6872
6912
}
6873
6913
my $f_found = 0;
6874
6914
my $f_hit = 0;
6875
6915
foreach my $key (@functionOrder ) {
6876
- my $data = $functionMap -> findKey($key );
6877
- my $line = $data -> line();
6916
+ my $data = $functionMap -> findKey($key );
6917
+ my $line = $data -> line();
6918
+ next unless $line > 0;
6878
6919
my $aliases = $data -> aliases();
6879
6920
foreach my $alias (sort keys %$aliases ) {
6880
6921
my $hit = $aliases -> {$alias };
@@ -6895,6 +6936,13 @@ sub write_info($$$)
6895
6936
6896
6937
foreach my $line (sort ({ $a <=> $b } $testbrcount -> keylist())) {
6897
6938
6939
+ if ($line <= 0) {
6940
+ lcovutil::ignorable_error(
6941
+ $lcovutil::ERROR_INCONSISTENT_DATA ,
6942
+ " \" $source_file \" : unexpected line number '$line ' in branch data record record '$_ '"
6943
+ );
6944
+ last ;
6945
+ }
6898
6946
my $brdata = $testbrcount -> value($line );
6899
6947
# want the block_id to be treated as 32-bit unsigned integer
6900
6948
# (need masking to match regression tests)
0 commit comments