shithub: rgbds

Download patch

ref: 12ba057b4f74a6ef4989d0ceb4075ef74bcc6ea2
parent: 0e0876b17f9c40c5a5e18dd4b536911451d5cfc1
author: ISSOtm <eldredhabert0@gmail.com>
date: Tue Oct 11 17:39:32 EDT 2022

Check that colour slot is non-empty before checking for gray-ness

This is otherwise UB, and trips a GLIBCXX assertion (when enabled).

--- a/src/gfx/process.cpp
+++ b/src/gfx/process.cpp
@@ -142,7 +142,7 @@
 		}
 		uint8_t bins = 0;
 		for (auto const &color : colors) {
-			if (color->isTransparent()) {
+			if (!color.has_value() || color->isTransparent()) {
 				continue;
 			}
 			if (!color->isGray()) {