Преглед изворни кода

_pack.c: Check for NULL return from Py_BuildValue.

Jelmer Vernooij пре 13 година
родитељ
комит
dd3df654d4
1 измењених фајлова са 7 додато и 2 уклоњено
  1. 7 2
      dulwich/_pack.c

+ 7 - 2
dulwich/_pack.c

@@ -79,7 +79,7 @@ static PyObject *py_apply_delta(PyObject *self, PyObject *args)
 	size_t outindex = 0;
 	int index;
 	uint8_t *out;
-	PyObject *ret, *py_src_buf, *py_delta;
+	PyObject *ret, *py_src_buf, *py_delta, *ret_list;
 
 	if (!PyArg_ParseTuple(args, "OO", &py_src_buf, &py_delta))
 		return NULL;
@@ -173,7 +173,12 @@ static PyObject *py_apply_delta(PyObject *self, PyObject *args)
 		return NULL;
 	}
 
-	return Py_BuildValue("[N]", ret);
+	ret_list = Py_BuildValue("[N]", ret);
+	if (ret_list == NULL) {
+		Py_DECREF(ret);
+		return NULL;
+	}
+	return ret_list;
 }
 
 static PyObject *py_bisect_find_sha(PyObject *self, PyObject *args)