QR decode: memleak might be fixed

This commit is contained in:
Thomas Farstrike
2025-05-15 16:38:53 +02:00
parent 65fe0ba84a
commit 6432b650cc
2 changed files with 13 additions and 9 deletions
+4 -3
View File
@@ -142,7 +142,8 @@ static mp_obj_t qrdecode_rgb565(mp_uint_t n_args, const mp_obj_t *args) {
mp_obj_new_int(height)
};
mp_obj_t result = MP_OBJ_NULL;
//mp_obj_t result = MP_OBJ_NULL;
mp_obj_t result = mp_const_none;
nlr_buf_t exception_handler;
if (nlr_push(&exception_handler) == 0) {
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) {
} else {
QRDECODE_DEBUG_PRINT("qrdecode_rgb565: Exception caught, freeing gray_buffer\n");
free(gray_buffer);
nlr_pop();
nlr_raise(exception_handler.ret_val);
//nlr_pop();
//nlr_raise(exception_handler.ret_val);
}
return result;
@@ -54,12 +54,15 @@ def qrdecode_live():
try:
import qrdecode
result = qrdecode.qrdecode_rgb565(current_cam_buffer, width, height)
#raise ValueError('A very specific bad thing happened.')
result = remove_bom(result)
result = print_qr_buffer(result)
print(f"QR decoding found: {result}")
status_label_text = result
stop_qr_decoding()
if not result:
status_label_text = status_label_text_searching
else:
#raise ValueError('A very specific bad thing happened.')
result = remove_bom(result)
result = print_qr_buffer(result)
print(f"QR decoding found: {result}")
status_label_text = result
stop_qr_decoding()
except ValueError as e:
print("QR ValueError: ", e)
status_label_text = status_label_text_searching