Allow nullptr with zero length in FileAccess get_buffer

fix #47071

(cherry picked from commit c28428fe4d)
This commit is contained in:
Alex Hirsch 2021-03-16 22:55:11 +01:00 committed by Rémi Verschelde
parent f1e8ec942d
commit 0b541af8a1
No known key found for this signature in database
GPG key ID: C3336907360768E1
9 changed files with 9 additions and 9 deletions

View file

@ -302,7 +302,7 @@ uint8_t FileAccessCompressed::get_8() const {
return ret; return ret;
} }
int FileAccessCompressed::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccessCompressed::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!p_dst, -1); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
ERR_FAIL_COND_V(p_length < 0, -1); ERR_FAIL_COND_V(p_length < 0, -1);
ERR_FAIL_COND_V_MSG(!f, -1, "File must be opened before use."); ERR_FAIL_COND_V_MSG(!f, -1, "File must be opened before use.");
ERR_FAIL_COND_V_MSG(writing, -1, "File has not been opened in read mode."); ERR_FAIL_COND_V_MSG(writing, -1, "File has not been opened in read mode.");

View file

@ -233,7 +233,7 @@ uint8_t FileAccessEncrypted::get_8() const {
} }
int FileAccessEncrypted::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccessEncrypted::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!p_dst, -1); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
ERR_FAIL_COND_V(p_length < 0, -1); ERR_FAIL_COND_V(p_length < 0, -1);
ERR_FAIL_COND_V_MSG(writing, -1, "File has not been opened in read mode."); ERR_FAIL_COND_V_MSG(writing, -1, "File has not been opened in read mode.");

View file

@ -150,7 +150,7 @@ uint8_t FileAccessMemory::get_8() const {
} }
int FileAccessMemory::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccessMemory::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!p_dst, -1); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
ERR_FAIL_COND_V(p_length < 0, -1); ERR_FAIL_COND_V(p_length < 0, -1);
ERR_FAIL_COND_V(!data, -1); ERR_FAIL_COND_V(!data, -1);

View file

@ -389,7 +389,7 @@ void FileAccessNetwork::_queue_page(int p_page) const {
} }
int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!p_dst, -1); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
ERR_FAIL_COND_V(p_length < 0, -1); ERR_FAIL_COND_V(p_length < 0, -1);
//bool eof=false; //bool eof=false;

View file

@ -284,7 +284,7 @@ uint8_t FileAccessPack::get_8() const {
} }
int FileAccessPack::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccessPack::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!p_dst, -1); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
ERR_FAIL_COND_V(p_length < 0, -1); ERR_FAIL_COND_V(p_length < 0, -1);
if (eof) if (eof)

View file

@ -332,7 +332,7 @@ uint8_t FileAccessZip::get_8() const {
} }
int FileAccessZip::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccessZip::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!p_dst, -1); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
ERR_FAIL_COND_V(p_length < 0, -1); ERR_FAIL_COND_V(p_length < 0, -1);
ERR_FAIL_COND_V(!zfile, -1); ERR_FAIL_COND_V(!zfile, -1);
at_eof = unzeof(zfile); at_eof = unzeof(zfile);

View file

@ -399,7 +399,7 @@ Vector<String> FileAccess::get_csv_line(const String &p_delim) const {
} }
int FileAccess::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccess::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!p_dst, -1); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
ERR_FAIL_COND_V(p_length < 0, -1); ERR_FAIL_COND_V(p_length < 0, -1);
int i = 0; int i = 0;
for (i = 0; i < p_length && !eof_reached(); i++) for (i = 0; i < p_length && !eof_reached(); i++)

View file

@ -248,7 +248,7 @@ uint8_t FileAccessUnix::get_8() const {
} }
int FileAccessUnix::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccessUnix::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!p_dst, -1); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
ERR_FAIL_COND_V(p_length < 0, -1); ERR_FAIL_COND_V(p_length < 0, -1);
ERR_FAIL_COND_V_MSG(!f, -1, "File must be opened before use."); ERR_FAIL_COND_V_MSG(!f, -1, "File must be opened before use.");
int read = fread(p_dst, 1, p_length, f); int read = fread(p_dst, 1, p_length, f);

View file

@ -259,7 +259,7 @@ uint8_t FileAccessWindows::get_8() const {
} }
int FileAccessWindows::get_buffer(uint8_t *p_dst, int p_length) const { int FileAccessWindows::get_buffer(uint8_t *p_dst, int p_length) const {
ERR_FAIL_COND_V(!p_dst, -1); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
ERR_FAIL_COND_V(p_length < 0, -1); ERR_FAIL_COND_V(p_length < 0, -1);
ERR_FAIL_COND_V(!f, -1); ERR_FAIL_COND_V(!f, -1);
if (flags == READ_WRITE || flags == WRITE_READ) { if (flags == READ_WRITE || flags == WRITE_READ) {