Update of /cvsroot/ltp/utils/analysis/lcov/bin
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31371/bin
Modified Files:
geninfo
Log Message:
geninfo: Tolerate garbage at end of gcno file
Some versions of gcc produce garbage at the end of a gcno file
when recompiling a source code file after removing some lines.
This patch makes geninfo's gcno file parser more robust by assuming
end-of-file when it finds a record that extends beyond the end-of-file.
Signed-off-by: Peter Oberparleiter <ob...@li...>
Index: geninfo
===================================================================
RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/geninfo,v
retrieving revision 1.125
retrieving revision 1.126
diff -C2 -d -r1.125 -r1.126
*** geninfo 13 Dec 2013 15:23:27 -0000 1.125
--- geninfo 13 Dec 2013 16:09:05 -0000 1.126
***************
*** 3385,3391 ****
--- 3385,3393 ----
my $instr;
my $graph;
+ my $filelength;
local *HANDLE;
open(HANDLE, "<", $gcno_filename) or goto open_error;
+ $filelength = (stat(HANDLE))[7];
binmode(HANDLE);
# Read magic
***************
*** 3419,3422 ****
--- 3421,3432 ----
goto tell_error if ($next_pos == -1);
$next_pos += $length;
+ # Catch garbage at the end of a gcno file
+ if ($next_pos > $filelength) {
+ debug("Overlong record: file_length=$filelength ".
+ "rec_length=$length\n");
+ warn("WARNING: $gcno_filename: Overlong record at end ".
+ "of file!\n");
+ last;
+ }
# Process record
if ($tag == $tag_function) {
|