From f2b44f582dbb9d898e6aad1db6919b5a295815be Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Thu, 14 Mar 2024 18:55:57 +0100 Subject: static analysis fixes --- src/windows/main_windows.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/windows/main_windows.cpp') diff --git a/src/windows/main_windows.cpp b/src/windows/main_windows.cpp index 948226f..45082ca 100644 --- a/src/windows/main_windows.cpp +++ b/src/windows/main_windows.cpp @@ -111,8 +111,9 @@ void ts_platform_set_window_title(utf8_int8_t* str) { int main(int, char**) { - OleInitialize(NULL); - CoInitializeEx(0, COINIT_MULTITHREADED|COINIT_DISABLE_OLE1DDE); + if (OleInitialize(NULL) != S_OK) { + return -1; + } ts_init(); @@ -322,7 +323,8 @@ ts_file_content ts_platform_read_file(char *path, const char *mode) } fseek(file, 0 , SEEK_END); - int length = ftell(file); + long length = ftell(file); + if (length == -1L) goto done_failure; fseek(file, 0, SEEK_SET); int length_to_alloc = length+1; @@ -330,8 +332,8 @@ ts_file_content ts_platform_read_file(char *path, const char *mode) result.content = malloc(length_to_alloc); if (!result.content) goto done; - memset(result.content, 0, length); - size_t read_result = fread(result.content, 1, length, file); + memset(result.content, 0, length_to_alloc); + size_t read_result = fread(result.content, 1, (size_t)length, file); if (read_result == 0 && length != 0) { free(result.content); -- cgit v1.2.3-70-g09d2