From 99d7ee2000f1fd6506b2587c6fd9a309b4f4389d Mon Sep 17 00:00:00 2001 From: White-Tiger Date: Sat, 20 May 2017 21:40:32 +0200 Subject: [PATCH] [api] fixed UTF-16 T-Clock.ini creation/update (thanks Dmytro) I messed it up in commit 2042b42. This is what I get by fixing non-important Coverity warnings :P [ci cov] --- src/DLL/clock_api.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/DLL/clock_api.c b/src/DLL/clock_api.c index cb83e933..1eaf41c0 100644 --- a/src/DLL/clock_api.c +++ b/src/DLL/clock_api.c @@ -93,7 +93,7 @@ static int ForceUTF_16(wchar_t* in_name, off_t file_size) { } UTF16file; char* in_data; UTF16file* out; - FILE* in_fp,* out_fp; + FILE* in_fp,* out_fp = 0; size_t out_len, len; wchar_t out_name[MAX_PATH]; int ret = 0; @@ -127,6 +127,7 @@ static int ForceUTF_16(wchar_t* in_name, off_t file_size) { } out_fp = _wfopen(out_name, L"wb"); if(out_fp) { + fclose(in_fp); ++out_len; out_len ^= fwrite(out, sizeof(wchar_t), out_len, out_fp); fclose(out_fp); @@ -140,7 +141,8 @@ static int ForceUTF_16(wchar_t* in_name, off_t file_size) { free(out); free(in_data); } - fclose(in_fp); + if(!out_fp) + fclose(in_fp); } return ret; }