ecos: detect potential ftell failure
ftell() potentially fails and returns -1. Found by Coverity Scan, CID 25546. Change-Id: Ifcf6fa8593cb1f3f54dbbff27ac021d46468a40c
This commit is contained in:
@ -176,8 +176,10 @@ std::vector<char> EcosKernelTestExperiment::loadFile(std::string filename)
|
|||||||
fseek(f, 0, SEEK_END);
|
fseek(f, 0, SEEK_END);
|
||||||
long len = ftell(f);
|
long len = ftell(f);
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
data.resize(len);
|
if (len > 0) {
|
||||||
fread(&data[0], len, 1, f);
|
data.resize(len);
|
||||||
|
fread(&data[0], len, 1, f);
|
||||||
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user