Details
Description
Run the following code. readAll() crashes with std::bad_alloc. The file size of QFile is big positive number when it should be 0.
#include <QApplication> #include <QtCore/QFile> #include <QtCore/QDebug> int main(int argc, char *argv[]) { for(;;) { int size = rand()%128; qDebug()<<size; char* data = (char*)malloc(size); for(int i=0;i<size;i++) data[i] = 'j'; free(data); QFile f; qDebug()<<"read list "<<QString::number((int)f.size()); f.readAll(); } return 0; }