Browse Source

Fix memory leak.

Jelmer Vernooij 16 years ago
parent
commit
f9aee4461e
1 changed files with 2 additions and 1 deletions
  1. 2 1
      dulwich/_pack.c

+ 2 - 1
dulwich/_pack.c

@@ -133,7 +133,6 @@ static PyObject *py_bisect_find_sha(PyObject *self, PyObject *args)
     char *sha;
     int sha_len;
 	int start, end;
-    int idx;
     if (!PyArg_ParseTuple(args, "iis#O", &start, &end, 
 						  &sha, &sha_len, &unpack_name))
         return NULL;
@@ -157,9 +156,11 @@ static PyObject *py_bisect_find_sha(PyObject *self, PyObject *args)
         }
         if (!py_is_sha(file_sha)) {
             PyErr_SetString(PyExc_TypeError, "unpack_name returned non-sha object");
+			Py_DECREF(file_sha);
             return NULL;
         }
         cmp = memcmp(PyString_AsString(file_sha), sha, 20);
+		Py_DECREF(file_sha);
         if (cmp < 0)
             start = i + 1;
         else if (cmp > 0)