diff --git a/Auxiliary/DirectXTexPNG.cpp b/Auxiliary/DirectXTexPNG.cpp index f8402456..6f20e7b1 100644 --- a/Auxiliary/DirectXTexPNG.cpp +++ b/Auxiliary/DirectXTexPNG.cpp @@ -126,6 +126,12 @@ namespace void Update() noexcept(false) { png_read_info(st, info); + // check for unsupported cases + png_byte interlacing = png_get_interlace_type(st, info); + if (interlacing != PNG_INTERLACE_NONE) + { + throw std::invalid_argument{ "interlacing not supported" }; + } // color handling png_byte color_type = png_get_color_type(st, info); if (color_type == PNG_COLOR_TYPE_GRAY) @@ -277,7 +283,7 @@ namespace color_type = PNG_COLOR_TYPE_RGBA; break; default: - return E_INVALIDARG; + return HRESULT_E_NOT_SUPPORTED; } png_set_IHDR(st, info, @@ -334,6 +340,10 @@ HRESULT DirectX::GetMetadataFromPNGFile( return (ec.code().value() == ENOENT) ? HRESULT_ERROR_FILE_NOT_FOUND : E_FAIL; #endif } + catch (const std::invalid_argument&) + { + return HRESULT_E_NOT_SUPPORTED; + } catch (const std::exception&) { return E_FAIL; @@ -375,6 +385,10 @@ HRESULT DirectX::LoadFromPNGFile( return (ec.code().value() == ENOENT) ? HRESULT_ERROR_FILE_NOT_FOUND : E_FAIL; #endif } + catch (const std::invalid_argument&) + { + return HRESULT_E_NOT_SUPPORTED; + } catch (const std::exception&) { image.Release();