diff options
author | Benjamin Dobell <benjamin.dobell+git@glassechidna.com.au> | 2012-10-07 14:33:16 +0200 |
---|---|---|
committer | Benjamin Dobell <benjamin.dobell+git@glassechidna.com.au> | 2012-10-07 14:33:44 +0200 |
commit | 8ac74126b4d8a295031ada29e3ff72d4fc5acbf4 (patch) | |
tree | ca070068b1f3f848bb09b38d5069d74cfcc71946 /heimdall/source/FlashAction.cpp | |
parent | Added missing reference& in heimdall/source/Arguments.cpp (diff) | |
download | Heimdall-8ac74126b4d8a295031ada29e3ff72d4fc5acbf4.tar Heimdall-8ac74126b4d8a295031ada29e3ff72d4fc5acbf4.tar.gz Heimdall-8ac74126b4d8a295031ada29e3ff72d4fc5acbf4.tar.bz2 Heimdall-8ac74126b4d8a295031ada29e3ff72d4fc5acbf4.tar.lz Heimdall-8ac74126b4d8a295031ada29e3ff72d4fc5acbf4.tar.xz Heimdall-8ac74126b4d8a295031ada29e3ff72d4fc5acbf4.tar.zst Heimdall-8ac74126b4d8a295031ada29e3ff72d4fc5acbf4.zip |
Diffstat (limited to 'heimdall/source/FlashAction.cpp')
-rw-r--r-- | heimdall/source/FlashAction.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/heimdall/source/FlashAction.cpp b/heimdall/source/FlashAction.cpp index d79235e..1ce8efb 100644 --- a/heimdall/source/FlashAction.cpp +++ b/heimdall/source/FlashAction.cpp @@ -444,21 +444,32 @@ static PitData *getPitData(const map<string, FILE *>& argumentFileMap, BridgeMan FILE *localPitFile = localPitFileIt->second; // Load the local pit file into memory. - unsigned char *pitFileBuffer = new unsigned char[4096]; - memset(pitFileBuffer, 0, 4096); - fseek(localPitFile, 0, SEEK_END); long localPitFileSize = ftell(localPitFile); rewind(localPitFile); + unsigned char *pitFileBuffer = new unsigned char[localPitFileSize]; + memset(pitFileBuffer, 0, localPitFileSize); + // dataRead is discarded, it's here to remove warnings. int dataRead = fread(pitFileBuffer, 1, localPitFileSize, localPitFile); - rewind(localPitFile); - localPitData = new PitData(); - localPitData->Unpack(pitFileBuffer); + if (dataRead > 0) + { + rewind(localPitFile); - delete [] pitFileBuffer; + localPitData = new PitData(); + localPitData->Unpack(pitFileBuffer); + + delete [] pitFileBuffer; + } + else + { + Interface::PrintError("Failed to read PIT file.\n"); + + delete [] pitFileBuffer; + return (nullptr); + } } if (repartition) |