Fixes UBSAN warnings, applying non-zero offset to null pointer.
Unified · Split
| @@ -80,7 +80,7 @@ void gl_upload_tex(GL *gl, GLenum target, GLenum format, GLenum type, · 79 unmodified lines | |||
| 80 | int x, int y, int w, int h) | 80 | int x, int y, int w, int h) |
| 81 | { | 81 | { |
| 82 | int bpp = gl_bytes_per_pixel(format, type); | 82 | int bpp = gl_bytes_per_pixel(format, type); |
| 83 | const uint8_t *data = dataptr; | 83 | uintptr_t data = (uintptr_t)dataptr; |
| 84 | int y_max = y + h; | 84 | int y_max = y + h; |
| 85 | if (w <= 0 || h <= 0 || !bpp) | 85 | if (w <= 0 || h <= 0 || !bpp) |
| 86 | return; | 86 | return; |
| @@ -95,11 +95,11 @@ void gl_upload_tex(GL *gl, GLenum target, GLenum format, GLenum type, · 8 unmodified lines | |||
| 95 | slice = 1; // very inefficient, but at least it works | 95 | slice = 1; // very inefficient, but at least it works |
| 96 | } | 96 | } |
| 97 | for (; y + slice <= y_max; y += slice) { | 97 | for (; y + slice <= y_max; y += slice) { |
| 98 | gl->TexSubImage2D(target, 0, x, y, w, slice, format, type, data); | 98 | gl->TexSubImage2D(target, 0, x, y, w, slice, format, type, (void *)data); |
| 99 | data += stride * slice; | 99 | data += stride * slice; |
| 100 | } | 100 | } |
| 101 | if (y < y_max) | 101 | if (y < y_max) |
| 102 | gl->TexSubImage2D(target, 0, x, y, w, y_max - y, format, type, data); | 102 | gl->TexSubImage2D(target, 0, x, y, w, y_max - y, format, type, (void *)data); |
| 103 | if (gl->mpgl_caps & MPGL_CAP_ROW_LENGTH) | 103 | if (gl->mpgl_caps & MPGL_CAP_ROW_LENGTH) |
| 104 | gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0); | 104 | gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0); |
| 105 | gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4); | 105 | gl->PixelStorei(GL_UNPACK_ALIGNMENT, 4); |