mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-21 14:16:08 +00:00
Fix segfault in EditFunctionMenu (#868)
This commit is contained in:
parent
f0fc9fc5e3
commit
528adf429a
@ -267,8 +267,6 @@ void DisassemblyContextMenu::aboutToShowSlot()
|
|||||||
actionAnalyzeFunction.setVisible(false);
|
actionAnalyzeFunction.setVisible(false);
|
||||||
actionRename.setVisible(true);
|
actionRename.setVisible(true);
|
||||||
actionRename.setText(tr("Rename function \"%1\"").arg(fcn->name));
|
actionRename.setText(tr("Rename function \"%1\"").arg(fcn->name));
|
||||||
actionEditFunction.setVisible(true);
|
|
||||||
actionEditFunction.setText(tr("Edit function \"%1\"").arg(fcn->name));
|
|
||||||
} else if (f) {
|
} else if (f) {
|
||||||
actionRename.setVisible(true);
|
actionRename.setVisible(true);
|
||||||
actionRename.setText(tr("Rename flag \"%1\"").arg(f->name));
|
actionRename.setText(tr("Rename flag \"%1\"").arg(f->name));
|
||||||
@ -280,10 +278,13 @@ void DisassemblyContextMenu::aboutToShowSlot()
|
|||||||
if(in_fcn)
|
if(in_fcn)
|
||||||
{
|
{
|
||||||
actionSetFunctionVarTypes.setVisible(true);
|
actionSetFunctionVarTypes.setVisible(true);
|
||||||
|
actionEditFunction.setVisible(true);
|
||||||
|
actionEditFunction.setText(tr("Edit function \"%1\"").arg(in_fcn->name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
actionSetFunctionVarTypes.setVisible(false);
|
actionSetFunctionVarTypes.setVisible(false);
|
||||||
|
actionEditFunction.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -693,38 +694,40 @@ void DisassemblyContextMenu::on_actionEditFunction_triggered()
|
|||||||
{
|
{
|
||||||
RCore *core = Core()->core();
|
RCore *core = Core()->core();
|
||||||
EditFunctionDialog *dialog = new EditFunctionDialog(this);
|
EditFunctionDialog *dialog = new EditFunctionDialog(this);
|
||||||
RAnalFunction *fcn = r_anal_get_fcn_at (core->anal, offset, R_ANAL_FCN_TYPE_NULL);
|
RAnalFunction *fcn = r_anal_get_fcn_in(core->anal, offset, 0);
|
||||||
|
|
||||||
dialog->setWindowTitle(tr("Edit function %1").arg(fcn->name));
|
if (fcn) {
|
||||||
dialog->setNameText(fcn->name);
|
dialog->setWindowTitle(tr("Edit function %1").arg(fcn->name));
|
||||||
|
dialog->setNameText(fcn->name);
|
||||||
|
|
||||||
QString startAddrText = "0x" + QString::number(fcn->addr, 16);
|
QString startAddrText = "0x" + QString::number(fcn->addr, 16);
|
||||||
dialog->setStartAddrText(startAddrText);
|
dialog->setStartAddrText(startAddrText);
|
||||||
|
|
||||||
QString endAddrText = "0x" + QString::number(fcn->addr + fcn->_size, 16);
|
QString endAddrText = "0x" + QString::number(fcn->addr + fcn->_size, 16);
|
||||||
dialog->setEndAddrText(endAddrText);
|
dialog->setEndAddrText(endAddrText);
|
||||||
|
|
||||||
QString stackSizeText;
|
QString stackSizeText;
|
||||||
stackSizeText.sprintf("%d", fcn->stack);
|
stackSizeText.sprintf("%d", fcn->stack);
|
||||||
dialog->setStackSizeText(stackSizeText);
|
dialog->setStackSizeText(stackSizeText);
|
||||||
|
|
||||||
QStringList callConList = Core()->cmd("afcl").split("\n");
|
QStringList callConList = Core()->cmd("afcl").split("\n");
|
||||||
callConList.removeLast();
|
callConList.removeLast();
|
||||||
dialog->setCallConList(callConList);
|
dialog->setCallConList(callConList);
|
||||||
dialog->setCallConSelected(fcn->cc);
|
dialog->setCallConSelected(fcn->cc);
|
||||||
|
|
||||||
|
|
||||||
if (dialog->exec()) {
|
if (dialog->exec()) {
|
||||||
QString new_name = dialog->getNameText();
|
QString new_name = dialog->getNameText();
|
||||||
Core()->renameFunction(fcn->name, new_name);
|
Core()->renameFunction(fcn->name, new_name);
|
||||||
QString new_start_addr = dialog->getStartAddrText();
|
QString new_start_addr = dialog->getStartAddrText();
|
||||||
fcn->addr = Core()->math(new_start_addr);
|
fcn->addr = Core()->math(new_start_addr);
|
||||||
QString new_end_addr = dialog->getEndAddrText();
|
QString new_end_addr = dialog->getEndAddrText();
|
||||||
Core()->cmd("afu " + new_end_addr);
|
Core()->cmd("afu " + new_end_addr);
|
||||||
QString new_stack_size = dialog->getStackSizeText();
|
QString new_stack_size = dialog->getStackSizeText();
|
||||||
fcn->stack = int(Core()->math(new_stack_size));
|
fcn->stack = int(Core()->math(new_stack_size));
|
||||||
Core()->cmd("afc " + dialog->getCallConSelected());
|
Core()->cmd("afc " + dialog->getCallConSelected());
|
||||||
emit Core()->functionsChanged();
|
emit Core()->functionsChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user