Unhandled exception in Windows, when opening
Describe the bug
In Windows, opening an XML file, instead of an image file, causes a crash due to an uncaught exception. The following error is shown:
terminate called after throwing an instance of 'Exiv2::BasicError<wchar_t>'
what(): filename: The file contains data of an unknown image type
The problem has been observed when using:
gboolean gexiv2_metadata_open_path(GExiv2Metadata* self, const gchar* path, GError** error);
but other load/save functions may have similar issues.
To Reproduce
The bug can be demonstrated using the gexiv2-tool
program. For a minimal example, use the partial_xml.txt file.
To trigger, use the following command:
$ ./gexiv2-tool.exe partial-xml.txt
terminate called after throwing an instance of 'Exiv2::BasicError<wchar_t>'
what(): partial-xml.txt: The file contains data of an unknown image type
The bug has been seen in commit 2a709213 (master), but is expected in the released 0.12.2
and 0.12.1
also.
Expected behaviour
When an error occurs, it should be handled gracefully with the GError** error
parameter set with an appropriate error message.
Desktop:
- OS: Windows (tested on Windows 10 with MinGW/MSYS2 (64-bit))
- Compiler & version: g++.exe (Rev2, Built by MSYS2 project) 10.3.0
- Non-default options: None
Additional context
The reason for the error, is that the gexiv2 Windows code uses the std::wstring
version of Exiv2's ImageFactory::open()
. This function can throw an Exiv2::WError
, as well as an Exiv2::Error
.