fix Coverity issues

This commit is contained in:
wmayer
2016-08-21 14:03:02 +02:00
parent 8cc3ee64e8
commit 0824c5fd3c
29 changed files with 621 additions and 543 deletions

View File

@@ -104,7 +104,7 @@ void PythonDebugModule::init_module(void)
PythonDebugStdout::init_type();
PythonDebugStderr::init_type();
PythonDebugExcept::init_type();
static PythonDebugModule* mod = new PythonDebugModule();
static PythonDebugModule* mod = new PythonDebugModule();
Q_UNUSED(mod);
}
@@ -352,6 +352,9 @@ struct PythonDebuggerP {
PythonDebuggerP(PythonDebugger* that) :
init(false), trystop(false), running(false)
{
out_o = 0;
err_o = 0;
exc_o = 0;
Base::PyGILStateLocker lock;
out_n = new PythonDebugStdout();
err_n = new PythonDebugStderr();
@@ -433,20 +436,20 @@ void PythonDebugger::runFile(const QString& fn)
module = PyImport_AddModule("__main__");
dict = PyModule_GetDict(module);
dict = PyDict_Copy(dict);
if (PyDict_GetItemString(dict, "__file__") == NULL) {
PyObject *f = PyString_FromString((const char*)pxFileName);
if (f == NULL) {
fclose(fp);
return;
}
if (PyDict_SetItemString(dict, "__file__", f) < 0) {
Py_DECREF(f);
fclose(fp);
return;
}
Py_DECREF(f);
}
if (PyDict_GetItemString(dict, "__file__") == NULL) {
PyObject *f = PyString_FromString((const char*)pxFileName);
if (f == NULL) {
fclose(fp);
return;
}
if (PyDict_SetItemString(dict, "__file__", f) < 0) {
Py_DECREF(f);
fclose(fp);
return;
}
Py_DECREF(f);
}
PyObject *result = PyRun_File(fp, (const char*)pxFileName, Py_file_input, dict, dict);
fclose(fp);
Py_DECREF(dict);
@@ -570,54 +573,54 @@ int PythonDebugger::tracer_callback(PyObject *obj, PyFrameObject *frame, int wha
PyErr_SetInterrupt();
QCoreApplication::processEvents();
//int no;
//no = frame->f_tstate->recursion_depth;
//std::string funcname = PyString_AsString(frame->f_code->co_name);
QString file = QString::fromUtf8(PyString_AsString(frame->f_code->co_filename));
switch (what) {
case PyTrace_CALL:
self->depth++;
return 0;
case PyTrace_RETURN:
if (self->depth > 0)
self->depth--;
return 0;
case PyTrace_LINE:
{
//PyObject *str;
//str = PyObject_Str(frame->f_code->co_filename);
//no = frame->f_lineno;
int line = PyCode_Addr2Line(frame->f_code, frame->f_lasti);
//if (str) {
// Base::Console().Message("PROFILING: %s:%d\n", PyString_AsString(str), frame->f_lineno);
// Py_DECREF(str);
//}
// For testing only
if (!dbg->d->trystop) {
Breakpoint bp = dbg->getBreakpoint(file);
if (bp.checkLine(line)) {
dbg->showDebugMarker(file, line);
//no = frame->f_tstate->recursion_depth;
//std::string funcname = PyString_AsString(frame->f_code->co_name);
QString file = QString::fromUtf8(PyString_AsString(frame->f_code->co_filename));
switch (what) {
case PyTrace_CALL:
self->depth++;
return 0;
case PyTrace_RETURN:
if (self->depth > 0)
self->depth--;
return 0;
case PyTrace_LINE:
{
//PyObject *str;
//str = PyObject_Str(frame->f_code->co_filename);
//no = frame->f_lineno;
int line = PyCode_Addr2Line(frame->f_code, frame->f_lasti);
//if (str) {
// Base::Console().Message("PROFILING: %s:%d\n", PyString_AsString(str), frame->f_lineno);
// Py_DECREF(str);
//}
// For testing only
if (!dbg->d->trystop) {
Breakpoint bp = dbg->getBreakpoint(file);
if (bp.checkLine(line)) {
dbg->showDebugMarker(file, line);
QEventLoop loop;
QObject::connect(dbg, SIGNAL(signalNextStep()), &loop, SLOT(quit()));
loop.exec();
dbg->hideDebugMarker(file);
}
}
return 0;
}
case PyTrace_EXCEPTION:
return 0;
case PyTrace_C_CALL:
return 0;
case PyTrace_C_EXCEPTION:
return 0;
case PyTrace_C_RETURN:
return 0;
default:
/* ignore PyTrace_EXCEPTION */
break;
}
return 0;
return 0;
}
case PyTrace_EXCEPTION:
return 0;
case PyTrace_C_CALL:
return 0;
case PyTrace_C_EXCEPTION:
return 0;
case PyTrace_C_RETURN:
return 0;
default:
/* ignore PyTrace_EXCEPTION */
break;
}
return 0;
}
#include "moc_PythonDebugger.cpp"