Skip to content

Commit adf3cb5

Browse files
committed
extmod/modframebuf: Store underlying buffer object to prevent GC free.
1 parent 5e39300 commit adf3cb5

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

extmod/modframebuf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
typedef struct _mp_obj_framebuf_t {
3939
mp_obj_base_t base;
40+
mp_obj_t buf_obj; // need to store this to prevent GC from reclaiming buf
4041
void *buf;
4142
uint16_t width, height, stride;
4243
uint8_t format;
@@ -133,6 +134,7 @@ STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, size
133134

134135
mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t);
135136
o->base.type = type;
137+
o->buf_obj = args[0];
136138

137139
mp_buffer_info_t bufinfo;
138140
mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_WRITE);

0 commit comments

Comments
 (0)