Commits

Anonymous committed 3ae8ec1 Draft

Tentative fix for a segmentation fault when creating the repr of an event object.

Comments (0)

Files changed (1)

inotify/_inotify.c

 		goto bail;
 
 	if (evt->name != Py_None) {
-		PyObject *pyname = PyObject_Repr(evt->name);
-
 		if (cookie == 0)
-			ret = PyUnicode_FromFormat("event(wd=%d, mask=%U, name=%V)",
-										wd, pymask, pyname, "???");
+			ret = PyUnicode_FromFormat("event(wd=%d, mask=%U, name=%U)",
+										wd, pymask, evt->name);
 		else
 			ret = PyUnicode_FromFormat("event(wd=%d, mask=%U, "
-										"cookie=0x%x, name=%V)",
-									wd, pymask, cookie, pyname, "???");
+										"cookie=0x%x, name=%U)",
+									wd, pymask, cookie, evt->name);
 
-		Py_XDECREF(pyname);
 	} else {
 		if (cookie == 0)
 			ret = PyUnicode_FromFormat("event(wd=%d, mask=%U)",
 			Py_INCREF(Py_None);
 			evt->cookie = Py_None;
 		}
-		if (in->len)
-			evt->name = PyUnicode_FromString(in->name);
-		else {
+
+		evt->name = in->len ? PyUnicode_FromString(in->name) : NULL;
+		if (evt->name == NULL) {
 			Py_INCREF(Py_None);
 			evt->name = Py_None;
 		}