Skip to content

Commit

Permalink
ViewerGL: add check to avoid crash
Browse files Browse the repository at this point in the history
  • Loading branch information
devernay committed Jan 9, 2018
1 parent 3abb226 commit b6c1799
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Gui/ViewerGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1274,10 +1274,13 @@ ViewerGL::transferBufferFromRAMtoGPU(const TextureTransferArgs& args)
if (ret) {
// update data directly on the mapped buffer
unsigned char* srcpixels = Image::pixelAtStatic(imageData.bounds.x1, imageData.bounds.y1, imageData.bounds, imageData.nComps, dataSizeOf, (unsigned char*)imageData.ptrs[0]);
std::memcpy(ret, srcpixels, bytesCount);
GLboolean result = GL_GPU::UnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB); // release the mapped buffer
assert(result == GL_TRUE);
Q_UNUSED(result);
assert(srcpixels);
if (srcpixels) {
std::memcpy(ret, srcpixels, bytesCount);
GLboolean result = GL_GPU::UnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB); // release the mapped buffer
assert(result == GL_TRUE);
Q_UNUSED(result);
}
}
glCheckError(GL_GPU);

Expand Down

0 comments on commit b6c1799

Please sign in to comment.