mirror of https://github.com/encounter/SDL.git
Disallow non-positive allocation.
Ensure that we're not trying to call SDL_small_alloc() with a count of zero. Transforming the code like this fixes a -Wmaybe-uninitialized warning from GCC 12.0.1
This commit is contained in:
parent
f81419702e
commit
9e5cbf034a
|
@ -2670,11 +2670,16 @@ static int
|
||||||
RenderDrawPointsWithRects(SDL_Renderer * renderer,
|
RenderDrawPointsWithRects(SDL_Renderer * renderer,
|
||||||
const SDL_Point * points, const int count)
|
const SDL_Point * points, const int count)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval;
|
||||||
SDL_bool isstack;
|
SDL_bool isstack;
|
||||||
SDL_FRect *frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
SDL_FRect *frects;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (count < 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
||||||
if (!frects) {
|
if (!frects) {
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
|
@ -2686,9 +2691,7 @@ RenderDrawPointsWithRects(SDL_Renderer * renderer,
|
||||||
frects[i].h = renderer->scale.y;
|
frects[i].h = renderer->scale.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count) {
|
retval = QueueCmdFillRects(renderer, frects, count);
|
||||||
retval = QueueCmdFillRects(renderer, frects, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_small_free(frects, isstack);
|
SDL_small_free(frects, isstack);
|
||||||
|
|
||||||
|
@ -2743,11 +2746,16 @@ static int
|
||||||
RenderDrawPointsWithRectsF(SDL_Renderer * renderer,
|
RenderDrawPointsWithRectsF(SDL_Renderer * renderer,
|
||||||
const SDL_FPoint * fpoints, const int count)
|
const SDL_FPoint * fpoints, const int count)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval;
|
||||||
SDL_bool isstack;
|
SDL_bool isstack;
|
||||||
SDL_FRect *frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
SDL_FRect *frects;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (count < 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
||||||
if (!frects) {
|
if (!frects) {
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
|
@ -2759,9 +2767,7 @@ RenderDrawPointsWithRectsF(SDL_Renderer * renderer,
|
||||||
frects[i].h = renderer->scale.y;
|
frects[i].h = renderer->scale.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count) {
|
retval = QueueCmdFillRects(renderer, frects, count);
|
||||||
retval = QueueCmdFillRects(renderer, frects, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_small_free(frects, isstack);
|
SDL_small_free(frects, isstack);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue