diff --git a/DirectXTex/DirectXTexD3D11.cpp b/DirectXTex/DirectXTexD3D11.cpp index 22a93c5..bc724a3 100644 --- a/DirectXTex/DirectXTexD3D11.cpp +++ b/DirectXTex/DirectXTexD3D11.cpp @@ -202,7 +202,11 @@ bool IsSupportedTexture( ID3D11Device* pDevice, const TexMetadata& metadata ) // Most cases are known apriori based on feature level, but we use this for robustness to handle the few optional cases UINT formatSupport = 0; - pDevice->CheckFormatSupport( fmt, &formatSupport ); + HRESULT hr = pDevice->CheckFormatSupport( fmt, &formatSupport ); + if ( FAILED(hr) ) + { + formatSupport = 0; + } switch ( metadata.dimension ) { @@ -363,7 +367,7 @@ HRESULT CreateTextureEx( ID3D11Device* pDevice, const Image* srcImages, size_t n return E_INVALIDARG; #endif - std::unique_ptr initData( new D3D11_SUBRESOURCE_DATA[ metadata.mipLevels * metadata.arraySize ] ); + std::unique_ptr initData( new (std::nothrow) D3D11_SUBRESOURCE_DATA[ metadata.mipLevels * metadata.arraySize ] ); if ( !initData ) return E_OUTOFMEMORY; diff --git a/DirectXTex/DirectXTexDDS.cpp b/DirectXTex/DirectXTexDDS.cpp index 73af518..ef3487d 100644 --- a/DirectXTex/DirectXTexDDS.cpp +++ b/DirectXTex/DirectXTexDDS.cpp @@ -911,7 +911,7 @@ static HRESULT _CopyImage( _In_reads_bytes_(size) const void* pPixels, _In_ size assert( pixelSize <= size ); - std::unique_ptr timages( new Image[nimages] ); + std::unique_ptr timages( new (std::nothrow) Image[nimages] ); if ( !_SetupImageArray( (uint8_t*)pPixels, size, metadata, cpFlags, timages.get(), nimages ) ) { return E_FAIL; @@ -1355,7 +1355,7 @@ HRESULT LoadFromDDSFile( LPCWSTR szFile, DWORD flags, TexMetadata* metadata, Scr std::unique_ptr pal8; if ( convFlags & CONV_FLAGS_PAL8 ) { - pal8.reset( new uint32_t[256] ); + pal8.reset( new (std::nothrow) uint32_t[256] ); if ( !pal8 ) { return E_OUTOFMEMORY; @@ -1384,7 +1384,7 @@ HRESULT LoadFromDDSFile( LPCWSTR szFile, DWORD flags, TexMetadata* metadata, Scr if ( (convFlags & CONV_FLAGS_EXPAND) || (flags & DDS_FLAGS_LEGACY_DWORD) ) { - std::unique_ptr temp( new uint8_t[ remaining ] ); + std::unique_ptr temp( new (std::nothrow) uint8_t[ remaining ] ); if ( !temp ) { image.Release(); diff --git a/DirectXTex/DirectXTexImage.cpp b/DirectXTex/DirectXTexImage.cpp index bc064ce..007d507 100644 --- a/DirectXTex/DirectXTexImage.cpp +++ b/DirectXTex/DirectXTexImage.cpp @@ -289,7 +289,7 @@ HRESULT ScratchImage::Initialize( const TexMetadata& mdata ) size_t pixelSize, nimages; _DetermineImageArray( _metadata, CP_FLAGS_NONE, nimages, pixelSize ); - _image = new Image[ nimages ]; + _image = new (std::nothrow) Image[ nimages ]; if ( !_image ) return E_OUTOFMEMORY; @@ -351,7 +351,7 @@ HRESULT ScratchImage::Initialize2D( DXGI_FORMAT fmt, size_t width, size_t height size_t pixelSize, nimages; _DetermineImageArray( _metadata, CP_FLAGS_NONE, nimages, pixelSize ); - _image = new Image[ nimages ]; + _image = new (std::nothrow) Image[ nimages ]; if ( !_image ) return E_OUTOFMEMORY; @@ -397,7 +397,7 @@ HRESULT ScratchImage::Initialize3D( DXGI_FORMAT fmt, size_t width, size_t height size_t pixelSize, nimages; _DetermineImageArray( _metadata, CP_FLAGS_NONE, nimages, pixelSize ); - _image = new Image[ nimages ]; + _image = new (std::nothrow) Image[ nimages ]; if ( !_image ) { Release(); diff --git a/DirectXTex/DirectXTexTGA.cpp b/DirectXTex/DirectXTexTGA.cpp index 4de2619..f253e0d 100644 --- a/DirectXTex/DirectXTexTGA.cpp +++ b/DirectXTex/DirectXTexTGA.cpp @@ -1167,7 +1167,7 @@ HRESULT LoadFromTGAFile( LPCWSTR szFile, TexMetadata* metadata, ScratchImage& im } else // RLE || EXPAND || INVERTX || !INVERTY { - std::unique_ptr temp( new uint8_t[ remaining ] ); + std::unique_ptr temp( new (std::nothrow) uint8_t[ remaining ] ); if ( !temp ) { image.Release(); @@ -1342,7 +1342,7 @@ HRESULT SaveToTGAFile( const Image& image, LPCWSTR szFile ) else { // Otherwise, write the image one scanline at a time... - std::unique_ptr temp( new uint8_t[ rowPitch ] ); + std::unique_ptr temp( new (std::nothrow) uint8_t[ rowPitch ] ); if ( !temp ) return E_OUTOFMEMORY;