Merge PR #373: Fix memory off-by-one overflow
This commit is contained in:
commit
5d6ca5a45a
@ -28,8 +28,7 @@ static int PyNymeaLoggingHandler_init(PyNymeaLoggingHandler *self, PyObject *arg
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->category = (char*)malloc(qstrlen(category));
|
self->category = qstrdup(category);
|
||||||
qstrcpy(self->category, category);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -37,7 +36,7 @@ static int PyNymeaLoggingHandler_init(PyNymeaLoggingHandler *self, PyObject *arg
|
|||||||
static void PyNymeaLoggingHandler_dealloc(PyNymeaLoggingHandler * self)
|
static void PyNymeaLoggingHandler_dealloc(PyNymeaLoggingHandler * self)
|
||||||
{
|
{
|
||||||
qCDebug(dcPythonIntegrations()) << "--- PyNymeaLoggingHandler";
|
qCDebug(dcPythonIntegrations()) << "--- PyNymeaLoggingHandler";
|
||||||
free(self->category);
|
delete[] self->category;
|
||||||
Py_TYPE(self)->tp_free(self);
|
Py_TYPE(self)->tp_free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,9 +30,8 @@ static int PyStdOutHandler_init(PyStdOutHandler *self, PyObject *args, PyObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->category = (char*)malloc(qstrlen(category));
|
self->category = qstrdup(category);
|
||||||
self->msgType = msgType;
|
self->msgType = msgType;
|
||||||
qstrcpy(self->category, category);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -40,7 +39,7 @@ static int PyStdOutHandler_init(PyStdOutHandler *self, PyObject *args, PyObject
|
|||||||
static void PyStdOutHandler_dealloc(PyStdOutHandler * self)
|
static void PyStdOutHandler_dealloc(PyStdOutHandler * self)
|
||||||
{
|
{
|
||||||
qCDebug(dcPythonIntegrations()) << "--- PyStdOutHandler";
|
qCDebug(dcPythonIntegrations()) << "--- PyStdOutHandler";
|
||||||
free(self->category);
|
delete[] self->category;
|
||||||
Py_TYPE(self)->tp_free(self);
|
Py_TYPE(self)->tp_free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user