From 6d30c38ff343a1ae37451c21cee21f459fafc0e5 Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Fri, 27 Jan 2023 15:17:56 +0000 Subject: [PATCH] dpx_file: Throw exception on invalid file read If dpx_read() fails to open a file for any reason, report the failure via a exception an return 0. Fixes #122 --- ctlrender/dpx_file.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ctlrender/dpx_file.cc b/ctlrender/dpx_file.cc index fb5ff56a..4c02693a 100644 --- a/ctlrender/dpx_file.cc +++ b/ctlrender/dpx_file.cc @@ -65,6 +65,12 @@ bool dpx_read(const char *name, float scale, ctl::dpx::fb *pixels, file.open(name); + if (file.fail()) + { + THROW(Iex::ArgExc, "dpx_read() cannot open input file " << std::string(name)); + return 0; + } + if(!ctl::dpx::check_magic(&file)) { return 0; }