Skip to content
  • Kevin H. Hobbs's avatar
    Reads past EOF are expected · 631d795b
    Kevin H. Hobbs authored
    The vtk3DSImporter reports errors like :
    
    ERROR: In /home/kevin/kitware/VTK/IO/Import/vtk3DSImporter.cxx, line
    1083
    vtk3DSImporter (0x75cd20): Pre-mature end of file in read_word
    
    on almost every machine in the dashboard.
    
    I did a bit of poking around with gdb and std::cerr, and it looks like
    these reads past the end of the file are not at all unexpected.
    
    For example parse_face_array uses read_word to read the number of faces
    and then to read what I assume are the face vertex ids: a failure here
    is catastrophic.
    
    Then even though importer->GetFileFD() could be at the end of the file
    it calls start_chunk which calls both read_word and read_dword to see if
    there is another (sub?)chunk to parse into.
    
    This commit adds two new functions peek_word and peek_dword that are
    exactly like read_word and read_dword except that they do not report an
    error when they read past the end of the file.
    
    peek_word and peek_dword replace read_word and read_dword in start_chunk
    where the read past the end of the file is not an error.
    
    read_dword is now unused
    
    Because read_dword is now unused, it should be removed.
    
    Stop leaking render windows
    
    Hopefully X and Mesa have advanced to the point where we can delete the
    render window without error.
    
    If any tested configurations still have trouble let us work around them
    more precisely.
    
    Change-Id: I90a68d1241379886d38d150ba00816d869c6675f
    631d795b