##// END OF EJS Templates
reachableroots: unify bail cases to raise exception correctly...
Yuya Nishihara -
r26016:c8d41c9c default
parent child Browse files
Show More
@@ -1154,13 +1154,13 b' static PyObject *reachableroots(indexObj'
1154 1154 tovisit = (int *)malloc((len + 1) * sizeof(int));
1155 1155 if (tovisit == NULL) {
1156 1156 PyErr_NoMemory();
1157 goto release_reachable;
1157 goto bail;
1158 1158 }
1159 1159
1160 1160 seen = (char *)calloc(len+1, 1);
1161 1161 if (seen == NULL) {
1162 1162 PyErr_NoMemory();
1163 goto release_seen_and_tovisit;
1163 goto bail;
1164 1164 }
1165 1165
1166 1166 /* Populate tovisit with all the heads */
@@ -1192,7 +1192,7 b' static PyObject *reachableroots(indexObj'
1192 1192 if (revnum != -1) {
1193 1193 r = index_get_parents(self, revnum, parents, (int)len - 1);
1194 1194 if (r < 0)
1195 goto release_seen_and_tovisit;
1195 goto bail;
1196 1196
1197 1197 for (i = 0; i < 2; i++) {
1198 1198 if (seen[parents[i] + 1] == 0 && parents[i] >= minroot) {
@@ -1214,7 +1214,7 b' static PyObject *reachableroots(indexObj'
1214 1214 r = index_get_parents(self, i, parents, (int)len - 1);
1215 1215 /* Corrupted index file, error is set from index_get_parents */
1216 1216 if (r < 0)
1217 goto release_seen_and_tovisit;
1217 goto bail;
1218 1218 for (k = 0; k < 2; k++) {
1219 1219 PyObject *p = PyInt_FromLong(parents[k]);
1220 1220 if (PySet_Contains(reachable, p) == 1)
@@ -1225,13 +1225,13 b' static PyObject *reachableroots(indexObj'
1225 1225 }
1226 1226 }
1227 1227
1228 release_seen_and_tovisit:
1229 1228 free(seen);
1230 1229 free(tovisit);
1231 1230 return reachable;
1232 release_reachable:
1231 bail:
1233 1232 Py_XDECREF(reachable);
1234 bail:
1233 free(seen);
1234 free(tovisit);
1235 1235 return NULL;
1236 1236 }
1237 1237
@@ -94,6 +94,8 b' Test corrupted p1/p2 fields that could c'
94 94 > cl = changelog.changelog(scmutil.vfs(sys.argv[1]))
95 95 > n0, n1 = cl.node(0), cl.node(1)
96 96 > ops = [
97 > ('reachableroots',
98 > lambda: cl.index.reachableroots(0, [1], set([0]), False)),
97 99 > ('compute_phases_map_sets', lambda: cl.computephases([[0], []])),
98 100 > ('index_headrevs', lambda: cl.headrevs()),
99 101 > ('find_gca_candidates', lambda: cl.commonancestorsheads(n0, n1)),
@@ -109,11 +111,13 b' Test corrupted p1/p2 fields that could c'
109 111 > EOF
110 112
111 113 $ python test.py limit/.hg/store
114 reachableroots: parent out of range
112 115 compute_phases_map_sets: parent out of range
113 116 index_headrevs: parent out of range
114 117 find_gca_candidates: parent out of range
115 118 find_deepest: parent out of range
116 119 $ python test.py segv/.hg/store
120 reachableroots: parent out of range
117 121 compute_phases_map_sets: parent out of range
118 122 index_headrevs: parent out of range
119 123 find_gca_candidates: parent out of range
General Comments 0
You need to be logged in to leave comments. Login now