FlashAction: fix FileOpen check
Check needs to be right after it is opened, before we try to seek in
it. Before this fix, heimdall segfaults if file does not exist.
Fixes commit 60ab9bbaff
("FlashAction: Make sure file fit partition
before flashing")
This commit is contained in:
parent
0cf817a591
commit
14f3521a6b
|
@ -116,16 +116,16 @@ static bool openFiles(Arguments& arguments, vector<PartitionFile>& partitionFile
|
|||
{
|
||||
const StringArgument *stringArgument = static_cast<const StringArgument *>(*it);
|
||||
FILE *file = FileOpen(stringArgument->GetValue().c_str(), "rb");
|
||||
FileSeek(file, 0, SEEK_END);
|
||||
unsigned long fileSize = (unsigned long)FileTell(file);
|
||||
FileRewind(file);
|
||||
|
||||
if (!file)
|
||||
{
|
||||
Interface::PrintError("Failed to open file \"%s\"\n", stringArgument->GetValue().c_str());
|
||||
return (false);
|
||||
}
|
||||
|
||||
FileSeek(file, 0, SEEK_END);
|
||||
unsigned long fileSize = (unsigned long)FileTell(file);
|
||||
FileRewind(file);
|
||||
|
||||
partitionFiles.push_back(PartitionFile(argumentName.c_str(), file, fileSize));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue