[nstool] Add checks to ensure a reader object is provided to the Process classes.

This commit is contained in:
jakcron 2018-04-25 19:36:58 +08:00
parent 167a343937
commit 3411118e26
3 changed files with 16 additions and 0 deletions

View file

@ -627,6 +627,12 @@ NpdmProcess::NpdmProcess() :
void NpdmProcess::process()
{
fnd::MemoryBlob scratch;
if (mReader == nullptr)
{
throw fnd::Exception(kModuleName, "No file reader set.");
}
scratch.alloc(mReader->size());
mReader->read(scratch.getBytes(), 0, scratch.getSize());

View file

@ -109,6 +109,11 @@ PfsProcess::PfsProcess() :
void PfsProcess::process()
{
fnd::MemoryBlob scratch;
if (mReader == nullptr)
{
throw fnd::Exception(kModuleName, "No file reader set.");
}
// open minimum header to get full header size
scratch.alloc(sizeof(nx::sPfsHeader));

View file

@ -192,6 +192,11 @@ XciProcess::XciProcess() :
void XciProcess::process()
{
fnd::MemoryBlob scratch;
if (mReader == nullptr)
{
throw fnd::Exception(kModuleName, "No file reader set.");
}
// read header page
mReader->read((byte_t*)&mHdrPage, mOffset, sizeof(nx::sXciHeaderPage));