mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 03:55:19 -04:00
Don't crash if out of memory resizing flags bitmaps in launcher
This commit is contained in:
parent
ddba7b8778
commit
9461bb5a65
@ -422,7 +422,7 @@ static cc_result Entity_EnsurePow2(struct Entity* e, Bitmap* bmp) {
|
||||
height = Math_NextPowOf2(bmp->Height);
|
||||
if (width == bmp->Width && height == bmp->Height) return 0;
|
||||
|
||||
Bitmap_Allocate(&scaled, width, height);
|
||||
Bitmap_TryAllocate(&scaled, width, height);
|
||||
if (!scaled.Scan0) return ERR_OUT_OF_MEMORY;
|
||||
|
||||
e->uScale = (float)bmp->Width / width;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "Window.h"
|
||||
#include "Options.h"
|
||||
#include "PackedCol.h"
|
||||
#include "Errors.h"
|
||||
|
||||
#ifndef CC_BUILD_WEB
|
||||
/*########################################################################################################################*
|
||||
@ -560,9 +561,12 @@ static void FetchFlagsTask_Scale(Bitmap* bmp) {
|
||||
/* at default DPI don't need to rescale it */
|
||||
if (width == bmp->Width && height == bmp->Height) return;
|
||||
|
||||
Bitmap_Allocate(&scaled, width, height);
|
||||
Bitmap_Scale(&scaled, bmp, 0, 0, bmp->Width, bmp->Height);
|
||||
Bitmap_TryAllocate(&scaled, width, height);
|
||||
if (!scaled.Scan0) {
|
||||
Logger_Warn(ERR_OUT_OF_MEMORY, "resizing flags bitmap"); return;
|
||||
}
|
||||
|
||||
Bitmap_Scale(&scaled, bmp, 0, 0, bmp->Width, bmp->Height);
|
||||
Mem_Free(bmp->Scan0);
|
||||
*bmp = scaled;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user