diff --git a/src/hll/DrawGraph.c b/src/hll/DrawGraph.c index 876a668..594d9fa 100644 --- a/src/hll/DrawGraph.c +++ b/src/hll/DrawGraph.c @@ -191,6 +191,12 @@ static void DrawGraph_CopyReverseAMapLR(int dst, int dx, int dy, int src, int sx static bool DrawGraph_GetAlphaColor(int surface, int x, int y, int *a) { + struct sact_sprite *sp = sact_get_sprite(surface); + // NOTE: System40.exe errors here + if (!sp) + VM_ERROR("Invalid sprite index: %d", surface); + if (x < 0 || x >= sp->rect.w || y < 0 || y >= sp->rect.h) + return false; *a = sact_SP_GetAMapValue(surface, x, y); return true; } diff --git a/src/hll/SACT2.c b/src/hll/SACT2.c index aa39ad1..ed9ddf6 100644 --- a/src/hll/SACT2.c +++ b/src/hll/SACT2.c @@ -568,6 +568,8 @@ int sact_SP_GetAMapValue(int sp_no, int x, int y) { struct sact_sprite *sp = sact_get_sprite(sp_no); if (!sp) return 0; + if (x < 0 || x >= sp->rect.w || y < 0 || y >= sp->rect.h) + return -1; return sprite_get_amap_value(sp, x, y); }