Skip to content

Commit 377af0f

Browse files
committed
Fix N42 files having a bunch of extra null bytes at end of file, not parsing.
1 parent 09c9cb9 commit 377af0f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/SpecFile_n42.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8856,6 +8856,12 @@ namespace SpecUtils
88568856
reset();
88578857

88588858
data_end = convert_n42_utf16_xml_to_utf8( data, data_end );
8859+
8860+
// Some times a bunch of null characters can get appended to the end
8861+
// of the file - lets remove them, or rapidxml::parse will fail.
8862+
// TODO: bet yet, we should look for the last '>' character, or even better, the last valid closing tag
8863+
while( ((data_end - data) > 2) && ((*(data_end - 1)) == '\0') )
8864+
--data_end;
88598865

88608866
if( !is_candidate_n42_file(data,data_end) )
88618867
return false;

0 commit comments

Comments
 (0)