Merge pull request #47079 from W4RH4WK/allow-nullptr-with-zero-length-get-buffer
Allow nullptr with zero length in FileAccess get_buffer
This commit is contained in:
commit
bc7e105821
@ -286,7 +286,7 @@ uint8_t FileAccessCompressed::get_8() 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_MSG(!f, -1, "File must be opened before use.");
|
||||
ERR_FAIL_COND_V_MSG(writing, -1, "File has not been opened in read mode.");
|
||||
|
@ -237,7 +237,7 @@ uint8_t FileAccessEncrypted::get_8() 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_MSG(writing, -1, "File has not been opened in read mode.");
|
||||
|
||||
|
@ -138,7 +138,7 @@ uint8_t FileAccessMemory::get_8() 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(!data, -1);
|
||||
|
||||
|
@ -366,7 +366,7 @@ void FileAccessNetwork::_queue_page(int p_page) 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);
|
||||
|
||||
//bool eof=false;
|
||||
|
@ -299,7 +299,7 @@ uint8_t FileAccessPack::get_8() 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);
|
||||
|
||||
if (eof) {
|
||||
|
@ -303,7 +303,7 @@ uint8_t FileAccessZip::get_8() 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(!zfile, -1);
|
||||
at_eof = unzeof(zfile);
|
||||
|
@ -368,7 +368,7 @@ Vector<String> FileAccess::get_csv_line(const String &p_delim) 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);
|
||||
int i = 0;
|
||||
for (i = 0; i < p_length && !eof_reached(); i++) {
|
||||
|
@ -240,7 +240,7 @@ uint8_t FileAccessUnix::get_8() 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_MSG(!f, -1, "File must be opened before use.");
|
||||
int read = fread(p_dst, 1, p_length, f);
|
||||
|
@ -253,7 +253,7 @@ uint8_t FileAccessWindows::get_8() 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(!f, -1);
|
||||
if (flags == READ_WRITE || flags == WRITE_READ) {
|
||||
|
Loading…
Reference in New Issue
Block a user