Browse Source

Added UBSAN complaint fix to rLoadTexture #1891 (#3321)

pull/3330/head
Christopher Odom 1 year ago
committed by GitHub
parent
commit
eb461512a7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      src/rlgl.h

+ 6
- 2
src/rlgl.h View File

@ -3009,11 +3009,15 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
TRACELOGD("TEXTURE: Load mipmap level %i (%i x %i), size: %i, offset: %i", i, mipWidth, mipHeight, mipSize, mipOffset);
// NOTE: Added pointer math separately from function to avoid UBSAN complaining
unsigned char *dataPtr = (unsigned char*)data;
if (mipOffset > 0) dataPtr = (unsigned char*)data + mipOffset;
if (glInternalFormat != -1)
{
if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) glTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, glFormat, glType, (unsigned char *)data + mipOffset);
if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) glTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, glFormat, glType, n">dataPtr);
#if !defined(GRAPHICS_API_OPENGL_11)
else glCompressedTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, mipSize, p">(unsigned char *)data + mipOffset);
else glCompressedTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, mipSize, n">dataPtr);
#endif
#if defined(GRAPHICS_API_OPENGL_33)

Loading…
Cancel
Save