From c1263ff9e18121b9503b80244f0653b1b28d846d Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Sun, 7 Feb 2021 17:20:22 +0100
Subject: [PATCH] fix(display): Do not free user memory in blit

---
 pycardium/modules/sys_display.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pycardium/modules/sys_display.c b/pycardium/modules/sys_display.c
index eedeb705e..37011cae8 100644
--- a/pycardium/modules/sys_display.c
+++ b/pycardium/modules/sys_display.c
@@ -150,7 +150,8 @@ static mp_obj_t mp_display_blit(size_t n_args, const mp_obj_t *args)
 		res = epic_disp_blit(pos_x, pos_y, width, height, buf, NULL);
 	}
 
-	if (buf) {
+	if (!rgb565) {
+		/* Do not free rgb565 data. It is owned by the caller */
 		m_free(buf);
 	}
 
-- 
GitLab