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.
This commit is contained in:
parent
2a80abaa7a
commit
39a26a0aa5
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user