Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-20372

QFile crashes on close(), when its FILE* handle is already closed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 4.6.3
    • None
    • Debian Linux (Squeeze)

    Description

      It could be a good idea, to check if the FILE pointer is valid with fileno().

      	// Open file handle
      	FILE* pFile = fopen( "/tmp/hugo.txt", "w+");
      	if( !pFile )
      	{
      		printf( "Error while opening file!\n" );
      		return 7;
      	}
      	// Create QFile from file handle
      	QSharedPointer<QFile> pSharedPointer(new QFile());
      	pSharedPointer->open( pFile, QIODevice::WriteOnly );
      
      	// close file handle
      	fclose( pFile );
      
      	// try to allocate the memory, where FILE* pointer points to
      	DoSomethingWhichAllocatesMemory();
      
      	// close QFile
      	pSharedPointer->close();
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            earthdomain Earth Domain (Inactive)
            bluespirit Karl Krach
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes