forked from qt-creator/qt-creator
ElfReader: Catch bad_alloc exception
Might happen on file.readAll() for large elf files. Change-Id: Id338e647d2d0903d2071b5f35ffc7a00e6aca24d Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -34,6 +34,8 @@
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
#include <new> // std::bad_alloc
|
||||
|
||||
namespace Utils {
|
||||
|
||||
quint16 getHalfWord(const unsigned char *&s, const ElfData &context)
|
||||
@@ -113,7 +115,11 @@ bool ElfMapper::map()
|
||||
ustart = file.map(0, fdlen);
|
||||
if (ustart == 0) {
|
||||
// Try reading the data into memory instead.
|
||||
try {
|
||||
raw = file.readAll();
|
||||
} catch (std::bad_alloc &) {
|
||||
return false;
|
||||
}
|
||||
start = raw.constData();
|
||||
fdlen = raw.size();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user