Merge pull request #40 from 0xeb/choose_ongetattr

+ bugfix: IDAPython: Choose.OnGetLineAttr was broken
This commit is contained in:
Arnaud Diederen
2023-01-18 10:09:31 +01:00
committed by GitHub
2 changed files with 12 additions and 8 deletions
+1
View File
@@ -326,6 +326,7 @@ struct ref_t
bool operator==(const ref_t &other) const { return o == other.o; }
bool operator!=(const ref_t &other) const { return !((*this) == other); }
explicit operator bool() const { return o != nullptr; }
};
//-------------------------------------------------------------------------
+11 -8
View File
@@ -478,15 +478,18 @@ void py_chooser_mixin_t::mixin_get_row(
PyObject_CallMethod(
self.o, (char *)S_ON_GET_LINE_ATTR,
"i", int(n)));
if ( PyErr_Occurred() != nullptr )
return;
if ( pyres.result != nullptr && PyList_Check(pyres.result.o) )
if ( PyErr_Occurred() == nullptr && pyres.result != nullptr && PySequence_Check(pyres.result.o) )
{
PyObject *item;
if ( (item = PyList_GetItem(pyres.result.o, 0)) != nullptr )
attrs->color = PyInt_AsLong(item);
if ( (item = PyList_GetItem(pyres.result.o, 1)) != nullptr )
attrs->flags = PyInt_AsLong(item);
{
newref_t item(PySequence_GetItem(pyres.result.o, 0));
if (item && PyLong_Check(item.o))
attrs->color = PyLong_AsUnsignedLong(item.o);
}
{
newref_t item(PySequence_GetItem(pyres.result.o, 1));
if (item && PyLong_Check(item.o))
attrs->flags = PyInt_AsLong(item.o);
}
}
}
}