From 73c4cce30366249fcb91e00cf0f4b201d595542c Mon Sep 17 00:00:00 2001 From: Syoyo Fujita Date: Tue, 28 Apr 2020 01:06:34 +0900 Subject: [PATCH] Return false for zero-sized asset. Fixes #255 --- tiny_gltf.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 710e9d9..2b0e674 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -2592,11 +2592,12 @@ bool ReadWholeFile(std::vector *out, std::string *err, return false; } size_t size = AAsset_getLength(asset); - if (size <= 0) { + if (size == 0) { if (err) { (*err) += "Invalid file size : " + filepath + " (does the path point to a directory?)"; } + return false; } out->resize(size); AAsset_read(asset, reinterpret_cast(&out->at(0)), size);