Use BLI_read instead of read to avoid issues with large files
Follow up to fix for #113473, similar issues exist elsewhere.
This commit is contained in:
@@ -219,7 +219,7 @@ PackedFile *BKE_packedfile_new(ReportList *reports, const char *filepath_rel, co
|
||||
/* #MEM_mallocN complains about `MEM_mallocN(0, "...")`,
|
||||
* a single allocation is harmless and doesn't cause any complications. */
|
||||
void *data = MEM_mallocN(std::max(file_size, size_t(1)), "packFile");
|
||||
if (read(file, data, file_size) == file_size) {
|
||||
if (BLI_read(file, data, file_size) == file_size) {
|
||||
pf = BKE_packedfile_new_from_memory(data, file_size);
|
||||
}
|
||||
else {
|
||||
@@ -398,13 +398,13 @@ enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name,
|
||||
len = sizeof(buf);
|
||||
}
|
||||
|
||||
if (read(file, buf, len) != len) {
|
||||
if (BLI_read(file, buf, len) != len) {
|
||||
/* read error ... */
|
||||
ret_val = PF_CMP_DIFFERS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (memcmp(buf, ((char *)pf->data) + i, len) != 0) {
|
||||
if (memcmp(buf, ((const char *)pf->data) + i, len) != 0) {
|
||||
ret_val = PF_CMP_DIFFERS;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef struct {
|
||||
static ssize_t file_read(FileReader *reader, void *buffer, size_t size)
|
||||
{
|
||||
RawFileReader *rawfile = (RawFileReader *)reader;
|
||||
ssize_t readsize = read(rawfile->filedes, buffer, size);
|
||||
ssize_t readsize = BLI_read(rawfile->filedes, buffer, size);
|
||||
|
||||
if (readsize >= 0) {
|
||||
rawfile->reader.offset += readsize;
|
||||
|
||||
@@ -720,7 +720,7 @@ static uchar *prefetch_read_file_to_memory(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (read(file, mem, size) != size) {
|
||||
if (BLI_read(file, mem, size) != size) {
|
||||
close(file);
|
||||
MEM_freeN(mem);
|
||||
return nullptr;
|
||||
|
||||
@@ -1329,7 +1329,7 @@ static uchar *proxy_thread_next_frame(ProxyQueue *queue,
|
||||
|
||||
mem = MEM_cnew_array<uchar>(size, "movieclip proxy memory file");
|
||||
|
||||
if (read(file, mem, size) != size) {
|
||||
if (BLI_read(file, mem, size) != size) {
|
||||
close(file);
|
||||
BLI_spin_unlock(&queue->spin);
|
||||
MEM_freeN(mem);
|
||||
|
||||
@@ -114,7 +114,7 @@ static ssize_t imb_ispic_read_header_from_filepath(const char *filepath, uchar b
|
||||
return -1;
|
||||
}
|
||||
|
||||
const ssize_t size = read(fp, buf, HEADER_SIZE);
|
||||
const ssize_t size = BLI_read(fp, buf, HEADER_SIZE);
|
||||
|
||||
close(fp);
|
||||
return size;
|
||||
|
||||
Reference in New Issue
Block a user