Great read, and fantastic debugging! Correct me if I'm wrong, but I think this bug would have been caught if a CMYK JPEG would've been tested, assuming that an extra component would break the accidental well-orderedness of the stream.
if (context.component_count != 1 && context.component_count != 3) {
dbgln_if(JPG_DEBUG, "{}: Unsupported number of components in SOF: {}!", stream.offset(), context.component_count);
return false;
}