mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 16:30:54 +01:00
Add file_size fail check for +2GB files
This commit is contained in:
parent
492f43a554
commit
5dc8d55c7f
@ -143,19 +143,14 @@ static STREAMFILE *open_stdio(STDIOSTREAMFILE *streamFile,const char * const fil
|
|||||||
}
|
}
|
||||||
|
|
||||||
static STREAMFILE * open_stdio_streamfile_buffer_by_file(FILE *infile,const char * const filename, size_t buffersize) {
|
static STREAMFILE * open_stdio_streamfile_buffer_by_file(FILE *infile,const char * const filename, size_t buffersize) {
|
||||||
uint8_t * buffer;
|
uint8_t * buffer = NULL;
|
||||||
STDIOSTREAMFILE * streamfile;
|
STDIOSTREAMFILE * streamfile = NULL;
|
||||||
|
|
||||||
buffer = calloc(buffersize,1);
|
buffer = calloc(buffersize,1);
|
||||||
if (!buffer) {
|
if (!buffer) goto fail;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
streamfile = calloc(1,sizeof(STDIOSTREAMFILE));
|
streamfile = calloc(1,sizeof(STDIOSTREAMFILE));
|
||||||
if (!streamfile) {
|
if (!streamfile) goto fail;
|
||||||
free(buffer);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
streamfile->sf.read = (void*)read_stdio;
|
streamfile->sf.read = (void*)read_stdio;
|
||||||
streamfile->sf.get_size = (void*)get_size_stdio;
|
streamfile->sf.get_size = (void*)get_size_stdio;
|
||||||
@ -175,7 +170,19 @@ static STREAMFILE * open_stdio_streamfile_buffer_by_file(FILE *infile,const char
|
|||||||
fseeko(streamfile->infile,0,SEEK_END);
|
fseeko(streamfile->infile,0,SEEK_END);
|
||||||
streamfile->filesize = ftello(streamfile->infile);
|
streamfile->filesize = ftello(streamfile->infile);
|
||||||
|
|
||||||
|
/* some compilers/flags may use ftell, which only handles up to ~2.14GB
|
||||||
|
* (possible for banks like FSB, though unlikely). */
|
||||||
|
if (streamfile->filesize == 0xFFFFFFFF) { /* -1 on error */
|
||||||
|
VGM_LOG("STREAMFILE: ftell error\n");
|
||||||
|
goto fail; /* can be ignored but may result in strange/unexpected behaviors */
|
||||||
|
}
|
||||||
|
|
||||||
return &streamfile->sf;
|
return &streamfile->sf;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
free(buffer);
|
||||||
|
free(streamfile);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static STREAMFILE * open_stdio_streamfile_buffer(const char * const filename, size_t buffersize) {
|
static STREAMFILE * open_stdio_streamfile_buffer(const char * const filename, size_t buffersize) {
|
||||||
|
Loading…
Reference in New Issue
Block a user