From: Wolfvak Date: Tue, 7 Jun 2016 23:28:28 +0000 (-0300) Subject: Forgot to close the file handle in loader X-Git-Tag: v0.0.7~1^2 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=refs%2Fpull%2F2%2Fhead;p=corbenik%2Fcorbenik.git Forgot to close the file handle in loader Warning: this was completely untested! Changes were made directly in the GitHub editor. --- diff --git a/external/loader/source/patcher.c b/external/loader/source/patcher.c index 332526e..0b33a4a 100644 --- a/external/loader/source/patcher.c +++ b/external/loader/source/patcher.c @@ -332,14 +332,9 @@ dump_code(u64 progId, u8 *code_loc, u32 code_len) progId >>= 4; } - if (R_SUCCEEDED(fileOpen(&code_f, ARCHIVE_SDMC, code_path, FS_OPEN_READ))) - // Code was already dumped, do nothing + if (!R_SUCCEEDED(fileOpen(&code_f, ARCHIVE_SDMC, code_path, FS_OPEN_READ))) { FSFILE_Close(code_f); - return; - } - - else { if (R_SUCCEEDED(fileOpen(&code_f, ARCHIVE_SDMC, code_path, FS_OPEN_WRITE | FS_OPEN_CREATE))) { u32 len = 0; FSFILE_Write(code_f, &len, 0, code_loc, code_len, FS_WRITE_FLUSH | FS_WRITE_UPDATE_TIME); @@ -348,6 +343,9 @@ dump_code(u64 progId, u8 *code_loc, u32 code_len) logstr("\n"); } } + // Code was already dumped, do nothing + + FSFILE_Close(code_f); return; }