From ac928b0456e3252f49de56c46e3750e1488bb3cc Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Sun, 15 Nov 2020 03:34:05 +1100 Subject: [PATCH] novidia: slightly better error handling (no real-world difference though tbh) --- source-code/source/plugins/Novidia/src/dllmain.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source-code/source/plugins/Novidia/src/dllmain.cpp b/source-code/source/plugins/Novidia/src/dllmain.cpp index 8e3d3c2..94a11cb 100644 --- a/source-code/source/plugins/Novidia/src/dllmain.cpp +++ b/source-code/source/plugins/Novidia/src/dllmain.cpp @@ -221,6 +221,7 @@ int64_t hookedGetFileSize(MsString* path) { shader_farc_data = NULL; shader_farc_data_size = 0; shader_farc_path = ""; + shader_file_handle = NULL; } @@ -300,7 +301,7 @@ int64_t hookedGetFileSize(MsString* path) { fclose(vcdfile); - + // allocate an output buffer and patch shader into it (needs to be done now to know correct size) outbuf_size = 64 * 1024 * 1024; // 64M should be enough outbuf = malloc(outbuf_size); @@ -350,9 +351,9 @@ int64_t hookedFread(void* dst, int64_t size, int64_t count, FILE* file) size_t size_bytes = size * count; - if (size_bytes > shader_farc_data_size) + if ((size_bytes > shader_farc_data_size) || !shader_farc_data) { - return divaFread(dst, size, count, file); // this is an error -- the game wants more data than we have for some reason + return divaFread(dst, size, count, file); // this is an error -- the game wants more data than we have for some reason, or size has a value but not our buffer } memcpy(dst, shader_farc_data, size_bytes);