Fix NULL pointer dereference in SDL_RenderGeometryRaw with NPOT textures (thanks @bleeqer!)
Fixes https://github.com/libsdl-org/SDL/issues/14329 Closes https://github.com/libsdl-org/SDL/pull/14331
This commit is contained in:
@@ -5291,8 +5291,8 @@ bool SDL_RenderGeometryRaw(SDL_Renderer *renderer,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int count = indices ? num_indices : num_vertices;
|
int count = indices ? num_indices : num_vertices;
|
||||||
SDL_TextureAddressMode texture_address_mode_u;
|
SDL_TextureAddressMode texture_address_mode_u = SDL_TEXTURE_ADDRESS_CLAMP;
|
||||||
SDL_TextureAddressMode texture_address_mode_v;
|
SDL_TextureAddressMode texture_address_mode_v = SDL_TEXTURE_ADDRESS_CLAMP;
|
||||||
|
|
||||||
CHECK_RENDERER_MAGIC(renderer, false);
|
CHECK_RENDERER_MAGIC(renderer, false);
|
||||||
|
|
||||||
@@ -5354,7 +5354,6 @@ bool SDL_RenderGeometryRaw(SDL_Renderer *renderer,
|
|||||||
if (texture->native) {
|
if (texture->native) {
|
||||||
texture = texture->native;
|
texture = texture->native;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (renderer->npot_texture_wrap_unsupported && IsNPOT(texture->w)) {
|
if (renderer->npot_texture_wrap_unsupported && IsNPOT(texture->w)) {
|
||||||
texture_address_mode_u = SDL_TEXTURE_ADDRESS_CLAMP;
|
texture_address_mode_u = SDL_TEXTURE_ADDRESS_CLAMP;
|
||||||
@@ -5366,9 +5365,9 @@ bool SDL_RenderGeometryRaw(SDL_Renderer *renderer,
|
|||||||
} else {
|
} else {
|
||||||
texture_address_mode_v = renderer->texture_address_mode_v;
|
texture_address_mode_v = renderer->texture_address_mode_v;
|
||||||
}
|
}
|
||||||
if (texture &&
|
|
||||||
(texture_address_mode_u == SDL_TEXTURE_ADDRESS_AUTO ||
|
if (texture_address_mode_u == SDL_TEXTURE_ADDRESS_AUTO ||
|
||||||
texture_address_mode_v == SDL_TEXTURE_ADDRESS_AUTO)) {
|
texture_address_mode_v == SDL_TEXTURE_ADDRESS_AUTO) {
|
||||||
for (i = 0; i < num_vertices; ++i) {
|
for (i = 0; i < num_vertices; ++i) {
|
||||||
const float *uv_ = (const float *)((const char *)uv + i * uv_stride);
|
const float *uv_ = (const float *)((const char *)uv + i * uv_stride);
|
||||||
float u = uv_[0];
|
float u = uv_[0];
|
||||||
@@ -5397,6 +5396,7 @@ bool SDL_RenderGeometryRaw(SDL_Renderer *renderer,
|
|||||||
texture_address_mode_v = SDL_TEXTURE_ADDRESS_CLAMP;
|
texture_address_mode_v = SDL_TEXTURE_ADDRESS_CLAMP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (indices) {
|
if (indices) {
|
||||||
for (i = 0; i < num_indices; ++i) {
|
for (i = 0; i < num_indices; ++i) {
|
||||||
|
|||||||
Reference in New Issue
Block a user