Fixed memory errors. (#4113)

This commit is contained in:
Branimir Karadžić
2026-10-31 21:02:37 -07:00
committed by GitHub
parent 9661260185
commit 00a1927c1f
5 changed files with 19 additions and 8 deletions
+4 -3
View File
@@ -108,11 +108,11 @@ namespace bgfx
int32_t len = bx::snprintf(out, sizeof(temp), "%s (%d): ", _filePath, _line);
int32_t total = len + bx::vsnprintf(out + len, sizeof(temp)-len, _format, argListCopy);
va_end(argListCopy);
if ( (int32_t)sizeof(temp) < total)
if ( (int32_t)sizeof(temp) <= total)
{
out = (char*)BX_STACK_ALLOC(total+1);
bx::memCopy(out, temp, len);
bx::vsnprintf(out + len, total-len, _format, _argList);
bx::vsnprintf(out + len, total-len+1, _format, _argList);
}
out[total] = '\0';
bx::debugOutput(out);
@@ -6118,7 +6118,6 @@ namespace bgfx
{
const Attachment& at = _attachment[ii];
const TextureHandle texHandle = at.handle;
const TextureRef& tr = s_ctx->m_textureRef[texHandle.idx];
BGFX_ERROR_CHECK(true
&& isValid(texHandle)
@@ -6131,6 +6130,8 @@ namespace bgfx
, texHandle.idx
);
const TextureRef& tr = s_ctx->m_textureRef[texHandle.idx];
BGFX_ERROR_CHECK(true
&& at.mip < tr.m_numMips
, _err
+2 -1
View File
@@ -7401,12 +7401,13 @@ namespace bgfx
void setNameForHandle(Handle _handle, const bx::StringView& _name)
{
char tmp[1024];
uint16_t len = 1+(uint16_t)bx::snprintf(tmp, BX_COUNTOF(tmp)
const int32_t total = bx::snprintf(tmp, BX_COUNTOF(tmp)
, "%sH %d: %S"
, _handle.getTypeName().abrvName
, _handle.idx
, &_name
);
const uint16_t len = uint16_t(bx::min<int32_t>(total, BX_COUNTOF(tmp) - 1) + 1);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::SetName);
cmdbuf.write(_handle);
+5 -2
View File
@@ -10096,7 +10096,7 @@ VK_DESTROY
: m_backBufferColorImageView[ii]
;
if (NULL != m_backBufferDepthStencilImageView)
if (VK_NULL_HANDLE != m_backBufferDepthStencilImageView)
{
attachments[numAttachments++] = m_backBufferDepthStencilImageView;
}
@@ -10759,7 +10759,10 @@ VK_DESTROY
const bool acquired = m_swapChain.acquire(_commandBuffer, _block);
m_needPresent = m_swapChain.m_needPresent;
m_currentFramebuffer = m_swapChain.m_backBufferFrameBuffer[m_swapChain.m_backBufferColorIdx];
m_currentFramebuffer = acquired
? m_swapChain.m_backBufferFrameBuffer[m_swapChain.m_backBufferColorIdx]
: VkFramebuffer(VK_NULL_HANDLE)
;
return acquired;
}
+2
View File
@@ -796,6 +796,7 @@ VK_DESTROY_FUNC(DescriptorSet);
, m_vsync(false)
, m_surface(VK_NULL_HANDLE)
, m_swapChain(VK_NULL_HANDLE)
, m_backBufferColorIdx(0)
, m_lastImageRenderedSemaphore(VK_NULL_HANDLE)
, m_lastImageAcquiredSemaphore(VK_NULL_HANDLE)
, m_needPresent(false)
@@ -895,6 +896,7 @@ VK_DESTROY_FUNC(DescriptorSet);
, m_numTh(0)
, m_nwh(NULL)
, m_needPresent(false)
, m_needResolve(false)
, m_framebuffer(VK_NULL_HANDLE)
, m_currentFramebuffer(VK_NULL_HANDLE)
{
+6 -2
View File
@@ -4421,12 +4421,16 @@ WGPU_IMPORT
bool hasStencil(TextureFormat::Enum _format)
{
return 0 < bimg::getBlockInfo(bimg::TextureFormat::Enum(_format) ).stencilBits;
return bimg::isDepth(bimg::TextureFormat::Enum(_format) )
&& 0 < bimg::getBlockInfo(bimg::TextureFormat::Enum(_format) ).stencilBits
;
}
bool hasDepth(TextureFormat::Enum _format)
{
return 0 < bimg::getBlockInfo(bimg::TextureFormat::Enum(_format) ).depthBits;
return bimg::isDepth(bimg::TextureFormat::Enum(_format) )
&& 0 < bimg::getBlockInfo(bimg::TextureFormat::Enum(_format) ).depthBits
;
}
void addAttachmentState(bx::HashMurmur3& _murmur, const FrameBufferWGPU& _fb) const