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 <QDir>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <new> // std::bad_alloc
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
quint16 getHalfWord(const unsigned char *&s, const ElfData &context)
|
quint16 getHalfWord(const unsigned char *&s, const ElfData &context)
|
||||||
@@ -113,7 +115,11 @@ bool ElfMapper::map()
|
|||||||
ustart = file.map(0, fdlen);
|
ustart = file.map(0, fdlen);
|
||||||
if (ustart == 0) {
|
if (ustart == 0) {
|
||||||
// Try reading the data into memory instead.
|
// Try reading the data into memory instead.
|
||||||
raw = file.readAll();
|
try {
|
||||||
|
raw = file.readAll();
|
||||||
|
} catch (std::bad_alloc &) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
start = raw.constData();
|
start = raw.constData();
|
||||||
fdlen = raw.size();
|
fdlen = raw.size();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user