mirror of
https://github.com/libretro/RetroArch.git
synced 2024-12-15 13:20:59 +00:00
lakka: Guard against the possibility of realloc failing
This commit is contained in:
parent
02a1d38912
commit
2c47dc171e
@ -257,10 +257,26 @@ void add_tween(float duration, float target_value, float* subject,
|
|||||||
easingFunc easing, tweenCallback callback)
|
easingFunc easing, tweenCallback callback)
|
||||||
{
|
{
|
||||||
tween_t *tween;
|
tween_t *tween;
|
||||||
|
tween_t *tweens_tmp;
|
||||||
|
|
||||||
numtweens++;
|
numtweens++;
|
||||||
|
|
||||||
tweens = (tween_t*)realloc(tweens, numtweens * sizeof(tween_t));
|
tweens_tmp = (tween_t*)realloc(tweens, numtweens * sizeof(tween_t));
|
||||||
|
if (tweens_tmp != NULL)
|
||||||
|
{
|
||||||
|
tweens = tweens_tmp;
|
||||||
|
}
|
||||||
|
else // realloc failed
|
||||||
|
{
|
||||||
|
if (tweens != NULL)
|
||||||
|
{
|
||||||
|
free(tweens);
|
||||||
|
tweens = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tween = (tween_t*)&tweens[numtweens-1];
|
tween = (tween_t*)&tweens[numtweens-1];
|
||||||
|
|
||||||
if (!tween)
|
if (!tween)
|
||||||
|
Loading…
Reference in New Issue
Block a user