Patchwork [1,of,2] reachableroots: handle error of PyList_Append()

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 22, 2015, 12:53 p.m.
Message ID <32fd293a3f4709841d1e.1440248026@mimosa>
Download mbox | patch
Permalink /patch/10251/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 22, 2015, 12:53 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1439635083 -32400
#      Sat Aug 15 19:38:03 2015 +0900
# Node ID 32fd293a3f4709841d1e555b9fe3040c086281a3
# Parent  607868eccaa7a351f604f3d5b62734b9670270df
reachableroots: handle error of PyList_Append()

Patch

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -1203,8 +1203,10 @@  static PyObject *reachableroots2(indexOb
 			val = PyInt_FromLong(revnum);
 			if (val == NULL)
 				goto bail;
-			PyList_Append(reachable, val);
+			r = PyList_Append(reachable, val);
 			Py_DECREF(val);
+			if (r < 0)
+				goto bail;
 			if (includepath == 0)
 				continue;
 		}
@@ -1245,8 +1247,10 @@  static PyObject *reachableroots2(indexOb
 					val = PyInt_FromLong(i);
 					if (val == NULL)
 						goto bail;
-					PyList_Append(reachable, val);
+					r = PyList_Append(reachable, val);
 					Py_DECREF(val);
+					if (r < 0)
+						goto bail;
 				}
 			}
 		}