From 12dca52bf09a6ed97850e5262b9dc2a15ef19b05 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 15 Feb 2015 15:06:13 -0500 Subject: Protect against misbehaving plugins. Also, test some misbehavior, and move our own annotations of plugins into prefixed attributes. --- coverage/tracer.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'coverage/tracer.c') diff --git a/coverage/tracer.c b/coverage/tracer.c index 102c474..a31340f 100644 --- a/coverage/tracer.c +++ b/coverage/tracer.c @@ -530,6 +530,9 @@ CTracer_trace(CTracer *self, PyFrameObject *frame, int what, PyObject *arg_unuse disp_file_tracer, "dynamic_source_filename", "OO", tracename, frame ); + if (next_tracename == NULL) { + goto error; + } Py_DECREF(tracename); tracename = next_tracename; @@ -577,7 +580,7 @@ CTracer_trace(CTracer *self, PyFrameObject *frame, int what, PyObject *arg_unuse /* If the disposition mentions a plugin, record that. */ if (disp_file_tracer != Py_None) { - disp_plugin_name = PyObject_GetAttrString(disp_file_tracer, "plugin_name"); + disp_plugin_name = PyObject_GetAttrString(disp_file_tracer, "_coverage_plugin_name"); if (disp_plugin_name == NULL) { goto error; } @@ -702,12 +705,13 @@ CTracer_trace(CTracer *self, PyFrameObject *frame, int what, PyObject *arg_unuse } ret = RET_OK; - goto ok; + goto cleanup; error: STATS( self->stats.errors++; ) -ok: +cleanup: + Py_XDECREF(tracename); Py_XDECREF(disposition); Py_XDECREF(disp_trace); -- cgit v1.2.1