diff --git a/source/fileop.cpp b/source/fileop.cpp index e399900..22c945d 100644 --- a/source/fileop.cpp +++ b/source/fileop.cpp @@ -863,6 +863,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 0ba6e63..37dfa64 100644 --- a/source/fileop.h +++ b/source/fileop.h @@ -21,7 +21,7 @@ #include #include -#define SAVEBUFFERSIZE (1024 * 512) +#define SAVEBUFFERSIZE (1024 * 1024 * 2) // leave room for IPS/UPS files and large images void InitDeviceThread(); void ResumeDeviceThread();