commit 5946138e9f33c509c2b92754a095cadeee682c87
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Wed Dec 31 12:41:17 2025 -0700
Commit: Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Wed Dec 31 12:41:17 2025 -0700
add sanity check to png parsing
---
source/cart.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/source/cart.cpp b/source/cart.cpp
index a8b5aaa..3f9bdfb 100644
--- a/source/cart.cpp
+++ b/source/cart.cpp
@@ -158,6 +158,9 @@ bool Cart::loadCartFromPng(std::vector<unsigned char> image) {
uint8_t version = 0;
for(size_t i = 0; i < imageBytes; i += 4) {
+ if (i + 3 >= imageBytes) {
+ break;
+ }
//get argb values
uint8_t r = image[i];
uint8_t g = image[i + 1];