From 39a26a0aa5e64858a54720432ffd1505cb25259f Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 1 Jul 2012 20:27:35 +0200 Subject: [PATCH] Ensure that the qrencode caches are cleared when aborting. The caches contain pointers into memory allocated by debug_malloc() that come from a pool that is destroied once the command returns. We therefore have to ensure that all such pointers are cleared in all cases before returning from the command or we will run into errors when executing the next commands. --- src/add-ons/kernel/debugger/qrencode/module.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/debugger/qrencode/module.cpp b/src/add-ons/kernel/debugger/qrencode/module.cpp index a030e621ab..54a52c53b2 100644 --- a/src/add-ons/kernel/debugger/qrencode/module.cpp +++ b/src/add-ons/kernel/debugger/qrencode/module.cpp @@ -51,7 +51,7 @@ move_to_and_clear_line(int line) } -static void +static bool print_qrcode(QRcode* qrCode, bool waitForKey) { move_to_and_clear_line(0); @@ -75,8 +75,10 @@ print_qrcode(QRcode* qrCode, bool waitForKey) if (waitForKey) { kputs("press q to abort or any other key to continue...\x1b[1B\x1b[G"); if (kgetc() == 'q') - abort_debugger_command(); + return false; } + + return true; } @@ -172,8 +174,14 @@ qrencode(int argc, char* argv[]) source += copyCount; inputLength -= copyCount; - print_qrcode(qrCode, inputLength > 0); + bool doContinue = print_qrcode(qrCode, inputLength > 0); QRcode_free(qrCode); + + if (!doContinue) { + QRcode_clearCache(); + abort_debugger_command(); + // Does not return. + } } QRcode_clearCache();