From b23af90947e539e6c556ad558ba7c039f9310812 Mon Sep 17 00:00:00 2001 From: jdryg Date: Fri, 24 Mar 2017 11:59:16 +0200 Subject: [PATCH] nvgRenderUpdateTexture() was reading past the end of the data buffer. --- examples/common/nanovg/nanovg_bgfx.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/common/nanovg/nanovg_bgfx.cpp b/examples/common/nanovg/nanovg_bgfx.cpp index 702f04ccd..ad6f800e7 100644 --- a/examples/common/nanovg/nanovg_bgfx.cpp +++ b/examples/common/nanovg/nanovg_bgfx.cpp @@ -363,6 +363,9 @@ namespace uint32_t bytesPerPixel = NVG_TEXTURE_RGBA == tex->type ? 4 : 1; uint32_t pitch = tex->width * bytesPerPixel; + const bgfx::Memory* mem = bgfx::alloc(w * h * bytesPerPixel); + bx::gather(mem->data, data + y * pitch + x * bytesPerPixel, w * bytesPerPixel, h, pitch); + bgfx::updateTexture2D( tex->id , 0 @@ -371,8 +374,8 @@ namespace , y , w , h - , bgfx::copy(data + y*pitch + x*bytesPerPixel, h*pitch) - , pitch + , mem + , UINT16_MAX ); return 1;