Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Audio/WaveBankReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName) noexcept(false)

if (m_data.dwFlags & BANKDATA::TYPE_STREAMING)
{
if (m_data.dwAlignment < ALIGNMENT_DVD)
if ((m_data.dwAlignment < ALIGNMENT_DVD) || (m_data.dwAlignment > ALIGNMENT_MAX))
return E_FAIL;
if (m_data.dwAlignment % DVD_SECTOR_SIZE)
return E_FAIL;
Expand Down Expand Up @@ -655,7 +655,7 @@ HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName) noexcept(false)
expectedSize = uint64_t(m_data.dwEntryCount) * m_data.dwEntryNameElementSize;
if (expectedSize > UINT32_MAX)
{
return E_FAIL;
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
}

if (namesBytes >= static_cast<DWORD>(expectedSize))
Expand Down Expand Up @@ -1185,7 +1185,9 @@ HRESULT WaveBankReader::Impl::GetMetadata(uint32_t index, Metadata& metadata) co
{
const uint64_t offset = uint64_t(metadata.offsetBytes) + uint64_t(m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwOffset);
if (offset > UINT32_MAX)
{
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
}

metadata.offsetBytes = static_cast<uint32_t>(offset);
}
Expand Down
3 changes: 2 additions & 1 deletion Src/BinaryReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#pragma once

#include <cstdint>
#include <memory>
#include <exception>
#include <stdexcept>
Expand Down Expand Up @@ -45,7 +46,7 @@ namespace DirectX
{
static_assert(std::is_standard_layout<T>::value, "Can only read plain-old-data types");

uint64_t byteCount = uint64_t(sizeof(T)) * uint64_t(elementCount);
const uint64_t byteCount = uint64_t(sizeof(T)) * uint64_t(elementCount);
if (byteCount > UINT32_MAX)
throw std::overflow_error("ReadArray");

Expand Down
Loading