nvgRenderUpdateTexture() was reading past the end of the data buffer.

This commit is contained in:
jdryg 2017-03-24 11:59:16 +02:00
parent 082b2a0c02
commit b23af90947

View File

@ -363,6 +363,9 @@ namespace
uint32_t bytesPerPixel = NVG_TEXTURE_RGBA == tex->type ? 4 : 1; uint32_t bytesPerPixel = NVG_TEXTURE_RGBA == tex->type ? 4 : 1;
uint32_t pitch = tex->width * bytesPerPixel; 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( bgfx::updateTexture2D(
tex->id tex->id
, 0 , 0
@ -371,8 +374,8 @@ namespace
, y , y
, w , w
, h , h
, bgfx::copy(data + y*pitch + x*bytesPerPixel, h*pitch) , mem
, pitch , UINT16_MAX
); );
return 1; return 1;