From 2d34099afc77c5e1a7529332f55b401468b16a35 Mon Sep 17 00:00:00 2001 From: Corwin Date: Fri, 24 May 2024 19:15:34 +0100 Subject: [PATCH] resize the buffer --- agb/src/panics_render.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agb/src/panics_render.rs b/agb/src/panics_render.rs index 77220e1c..6acfa5b2 100644 --- a/agb/src/panics_render.rs +++ b/agb/src/panics_render.rs @@ -73,15 +73,19 @@ const PADDING: i32 = 8; /// Returns the width / height of the QR code + padding in pixels fn draw_qr_code(gfx: &mut Bitmap3<'_>, qrcode_string_data: &str) -> i32 { const MAX_VERSION: qrcodegen_no_heap::Version = qrcodegen_no_heap::Version::new(6); + let buffer_len = MAX_VERSION.buffer_len(); let (Ok(mut temp_buffer), Ok(mut out_buffer)) = ( - Vec::try_with_capacity_in(MAX_VERSION.buffer_len(), crate::ExternalAllocator), - Vec::try_with_capacity_in(MAX_VERSION.buffer_len(), crate::ExternalAllocator), + Vec::try_with_capacity_in(buffer_len, crate::ExternalAllocator), + Vec::try_with_capacity_in(buffer_len, crate::ExternalAllocator), ) else { crate::println!("Failed to allocate memory to generate QR code"); return PADDING; }; + temp_buffer.resize(buffer_len, 0); + out_buffer.resize(buffer_len, 0); + let qr_code = match qrcodegen_no_heap::QrCode::encode_text( qrcode_string_data, &mut temp_buffer,