diff --git a/source/fileop.cpp b/source/fileop.cpp index da04a88..d80c7bf 100644 --- a/source/fileop.cpp +++ b/source/fileop.cpp @@ -871,6 +871,18 @@ LoadFile (char * rbuffer, char *filepath, size_t length, bool silent) size_t LoadFile(char * filepath, bool silent) { + struct stat filestat; + + if(stat(filepath, &filestat) != 0) { + return 0; + } + + int size = filestat.st_size; + + if(size >= SAVEBUFFERSIZE) { + return 0; + } + return LoadFile((char *)savebuffer, filepath, 0, silent); } diff --git a/source/fileop.h b/source/fileop.h index 9ff49d3..569200f 100644 --- a/source/fileop.h +++ b/source/fileop.h @@ -18,7 +18,7 @@ #include #include -#define SAVEBUFFERSIZE (1024 * 512) +#define SAVEBUFFERSIZE (1024 * 1024 * 2) // leave room for IPS/UPS files and larger images void InitDeviceThread(); void ResumeDeviceThread();