Return false for zero-sized asset. Fixes #255

This commit is contained in:
Syoyo Fujita 2020-04-28 01:06:34 +09:00
parent 925b83627a
commit 73c4cce303

View File

@ -2592,11 +2592,12 @@ bool ReadWholeFile(std::vector<unsigned char> *out, std::string *err,
return false; return false;
} }
size_t size = AAsset_getLength(asset); size_t size = AAsset_getLength(asset);
if (size <= 0) { if (size == 0) {
if (err) { if (err) {
(*err) += "Invalid file size : " + filepath + (*err) += "Invalid file size : " + filepath +
" (does the path point to a directory?)"; " (does the path point to a directory?)";
} }
return false;
} }
out->resize(size); out->resize(size);
AAsset_read(asset, reinterpret_cast<char *>(&out->at(0)), size); AAsset_read(asset, reinterpret_cast<char *>(&out->at(0)), size);