From a98cefe5a4b53d7bc345a0ca8c8799464cc3b278 Mon Sep 17 00:00:00 2001 From: salix5 Date: Tue, 8 Oct 2024 01:13:36 +0800 Subject: [PATCH 1/2] fix default_script_reader --- ocgapi.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ocgapi.cpp b/ocgapi.cpp index 834f98366..56be88c2d 100644 --- a/ocgapi.cpp +++ b/ocgapi.cpp @@ -44,12 +44,12 @@ byte* default_script_reader(const char* script_name, int* slen) { FILE *fp; fp = std::fopen(script_name, "rb"); if (!fp) - return 0; - int len = (int)fread(buffer, 1, sizeof(buffer), fp); + return nullptr; + size_t len = std::fread(buffer, 1, sizeof buffer, fp); std::fclose(fp); - if(len >= sizeof(buffer)) - return 0; - *slen = len; + if (len >= sizeof buffer) + return nullptr; + *slen = (int)len; return buffer; } uint32 default_card_reader(uint32 code, card_data* data) { From 26c8fbca6d81f18c5a8304561c05eba37b9f06db Mon Sep 17 00:00:00 2001 From: salix5 Date: Tue, 8 Oct 2024 01:21:42 +0800 Subject: [PATCH 2/2] fix type --- interpreter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interpreter.cpp b/interpreter.cpp index e0963c1d9..4c6f45f18 100644 --- a/interpreter.cpp +++ b/interpreter.cpp @@ -121,7 +121,7 @@ void interpreter::unregister_group(group *pgroup) { pgroup->ref_handle = 0; } int32 interpreter::load_script(const char* script_name) { - int32 len = 0; + int len = 0; byte* buffer = ::read_script(script_name, &len); if (!buffer) return OPERATION_FAIL;