mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 19:36:11 +00:00
Fix sidebar crash (#99)
* Fix crash on invalid asm/hex Added nullptr checks because the called functions can (and will) return NULL * Call disassemble when hex2asm is clicked * Change order on != comparison * Fix missing whitspace
This commit is contained in:
parent
cd1df4e08c
commit
0c69988f83
@ -511,14 +511,14 @@ void QRCore::setDefaultCPU() {
|
||||
|
||||
QString QRCore::assemble(const QString &code) {
|
||||
RAsmCode *ac = r_asm_massemble (core->assembler, code.toUtf8().constData());
|
||||
QString hex = QString(ac->buf_hex);
|
||||
QString hex(ac != nullptr ? ac->buf_hex : "");
|
||||
r_asm_code_free (ac);
|
||||
return hex;
|
||||
}
|
||||
|
||||
QString QRCore::disassemble(const QString &hex) {
|
||||
RAsmCode *ac = r_asm_mdisassemble_hexstr(core->assembler, hex.toUtf8().constData());
|
||||
QString code = QString (ac->buf_asm);
|
||||
QString code = QString (ac != nullptr ? ac->buf_asm : "");
|
||||
r_asm_code_free (ac);
|
||||
return code;
|
||||
}
|
||||
@ -540,7 +540,7 @@ int QRCore::get_size()
|
||||
{
|
||||
RBinObject *obj = r_bin_get_object(core->bin);
|
||||
//return obj->size;
|
||||
return obj->obj_size;
|
||||
return obj != nullptr ? obj->obj_size : 0;
|
||||
}
|
||||
|
||||
ulong QRCore::get_baddr()
|
||||
|
@ -89,7 +89,7 @@ void SideBar::on_asm2hex_clicked()
|
||||
|
||||
void SideBar::on_hex2asm_clicked()
|
||||
{
|
||||
ui->asmInput->setPlainText(main->core->assemble(ui->hexInput->toPlainText()));
|
||||
ui->asmInput->setPlainText(main->core->disassemble(ui->hexInput->toPlainText()));
|
||||
}
|
||||
|
||||
void SideBar::on_respButton_toggled(bool checked)
|
||||
|
Loading…
Reference in New Issue
Block a user