In the problematic case, header.comments_offset was 0, which caused an exception when trying to skip forward in the file to this offset.