Changeset 8295

Show
Ignore:
Timestamp:
05/09/08 13:27:03
Author:
robert
Message:

From Paul Martz, "Attached are some minor plugin fixes. PNM, RGB, and JPEG would all crash if attempting to read an empty file, and FLT would go into an infinite loop. All are fixed with this change.


I also fixed some return values for a couple of these, changing FILE_NOT_HANDLED to ERROR_IN_READING_FILE where appropriate."

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp

    r8010 r8295  
    300300                size_type   size   = (size_type)dataStream.readUInt16(); 
    301301 
     302                if (size==0) 
     303                    return ReadResult::ERROR_IN_READING_FILE; 
     304 
    302305                // variable length record complete? 
    303306                if (!continuationBuffer.empty() && opcode!=CONTINUATION_OP) 
  • OpenSceneGraph/trunk/src/osgPlugins/jpeg/ReaderWriterJPEG.cpp

    r7878 r8295  
    615615        WriteResult::WriteStatus write_JPEG_file (std::ostream &fout,int image_width,int image_height,JSAMPLE* image_buffer,int quality = 100) const 
    616616        { 
     617            if ( (image_width == 0) || (image_height == 0) ) 
     618                return WriteResult::ERROR_IN_WRITING_FILE; 
     619 
    617620            /* This struct contains the JPEG compression parameters and pointers to 
    618621            * working space (which is allocated as needed by the JPEG library). 
  • OpenSceneGraph/trunk/src/osgPlugins/pnm/ReaderWriterPNM.cpp

    r7076 r8295  
    280280            for (row = 1; row <= 3; row++) 
    281281            { 
    282                 fgets(line, 300, fp); 
     282                if ( fgets(line, 300, fp) == NULL) 
     283                    break; 
    283284 
    284285                char *cp = line; 
     
    327328            { 
    328329                fclose(fp); 
    329                 return ReadResult::FILE_NOT_HANDLED
     330                return ReadResult::ERROR_IN_READING_FILE
    330331            } 
    331332 
  • OpenSceneGraph/trunk/src/osgPlugins/rgb/ReaderWriterRGB.cpp

    r7878 r8295  
    169169 
    170170    fin.read((char*)raw,12); 
     171    if (!fin.good()) 
     172        return NULL; 
    171173 
    172174    if (raw->swapFlag) 
     
    460462            if( (raw = RawImageOpen(fin)) == NULL ) 
    461463            { 
    462                 return ReadResult::FILE_NOT_HANDLED
     464                return ReadResult::ERROR_IN_READING_FILE
    463465            } 
    464466