Skip to content

Commit 6432b65

Browse files
QR decode: memleak might be fixed
1 parent 65fe0ba commit 6432b65

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

c_mpos/src/quirc_decode.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ static mp_obj_t qrdecode_rgb565(mp_uint_t n_args, const mp_obj_t *args) {
142142
mp_obj_new_int(height)
143143
};
144144

145-
mp_obj_t result = MP_OBJ_NULL;
145+
//mp_obj_t result = MP_OBJ_NULL;
146+
mp_obj_t result = mp_const_none;
146147
nlr_buf_t exception_handler;
147148
if (nlr_push(&exception_handler) == 0) {
148149
result = qrdecode(3, gray_args);
@@ -152,8 +153,8 @@ static mp_obj_t qrdecode_rgb565(mp_uint_t n_args, const mp_obj_t *args) {
152153
} else {
153154
QRDECODE_DEBUG_PRINT("qrdecode_rgb565: Exception caught, freeing gray_buffer\n");
154155
free(gray_buffer);
155-
nlr_pop();
156-
nlr_raise(exception_handler.ret_val);
156+
//nlr_pop();
157+
//nlr_raise(exception_handler.ret_val);
157158
}
158159

159160
return result;

internal_filesystem/apps/com.example.camtest/assets/camtest.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,15 @@ def qrdecode_live():
5454
try:
5555
import qrdecode
5656
result = qrdecode.qrdecode_rgb565(current_cam_buffer, width, height)
57-
#raise ValueError('A very specific bad thing happened.')
58-
result = remove_bom(result)
59-
result = print_qr_buffer(result)
60-
print(f"QR decoding found: {result}")
61-
status_label_text = result
62-
stop_qr_decoding()
57+
if not result:
58+
status_label_text = status_label_text_searching
59+
else:
60+
#raise ValueError('A very specific bad thing happened.')
61+
result = remove_bom(result)
62+
result = print_qr_buffer(result)
63+
print(f"QR decoding found: {result}")
64+
status_label_text = result
65+
stop_qr_decoding()
6366
except ValueError as e:
6467
print("QR ValueError: ", e)
6568
status_label_text = status_label_text_searching

0 commit comments

Comments
 (0)