From 230726ae6bd23dd171e40dcbd3e35d406e344796 Mon Sep 17 00:00:00 2001 From: Alberth Date: Mon, 26 May 2025 21:34:04 +0200 Subject: [PATCH] Check file handle of output file as well. --- tools/rnc/rnc_decode_cli.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/rnc/rnc_decode_cli.cpp b/tools/rnc/rnc_decode_cli.cpp index 9429b969..7e60ed73 100644 --- a/tools/rnc/rnc_decode_cli.cpp +++ b/tools/rnc/rnc_decode_cli.cpp @@ -115,6 +115,10 @@ int main(int argc, char* argv[]) { std::uint8_t* outdata = decompress(indata, insize, &outlen); FILE* outhandle = fopen(argv[2], "wb"); + if (outhandle == nullptr) { + fprintf(stderr, "Cannot open output file.\n"); + exit(1); + } count = fwrite(outdata, 1, outlen, outhandle); if (count != outlen) { fprintf(stderr, "Cannot write output file.\n");