diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-14 18:55:57 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-14 18:55:57 +0100 |
| commit | f2b44f582dbb9d898e6aad1db6919b5a295815be (patch) | |
| tree | 4c4b495c5c063a308c19e932c14aca45e7500954 /src/windows/main_windows.cpp | |
| parent | 33caee123ae6e79f251d1cd9d45ca62332e8d55b (diff) | |
static analysis fixes
Diffstat (limited to 'src/windows/main_windows.cpp')
| -rw-r--r-- | src/windows/main_windows.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
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); |
