The change looks correct to me, but I'm confused why using comp_mode uninitialized caused a crash.
It's because if the uninitialized value happens to be CompositingModeSourceCopy we set pixels unconditionally, but the test passes an invalid buffer to verify that only modified pixels are being updated.