Skip to content

Commit bbe8cd9

Browse files
committed
Arrange things so DECREF(temp) happens even if sym_new_const() runs out of space
1 parent d2078db commit bbe8cd9

File tree

2 files changed

+36
-24
lines changed

2 files changed

+36
-24
lines changed

Python/optimizer_bytecodes.c

+18-12
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ dummy_func(void) {
118118
if (temp == NULL) {
119119
goto error;
120120
}
121-
OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp));
121+
res = sym_new_const(ctx, temp);
122+
Py_DECREF(temp);
123+
OUT_OF_SPACE_IF_NULL(res);
122124
// TODO gh-115506:
123125
// replace opcode with constant propagated one and add tests!
124-
Py_DECREF(temp);
125126
}
126127
else {
127128
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyLong_Type));
@@ -139,10 +140,11 @@ dummy_func(void) {
139140
if (temp == NULL) {
140141
goto error;
141142
}
142-
OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp));
143+
res = sym_new_const(ctx, temp);
144+
Py_DECREF(temp);
145+
OUT_OF_SPACE_IF_NULL(res);
143146
// TODO gh-115506:
144147
// replace opcode with constant propagated one and add tests!
145-
Py_DECREF(temp);
146148
}
147149
else {
148150
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyLong_Type));
@@ -160,10 +162,11 @@ dummy_func(void) {
160162
if (temp == NULL) {
161163
goto error;
162164
}
163-
OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp));
165+
res = sym_new_const(ctx, temp);
166+
Py_DECREF(temp);
167+
OUT_OF_SPACE_IF_NULL(res);
164168
// TODO gh-115506:
165169
// replace opcode with constant propagated one and add tests!
166-
Py_DECREF(temp);
167170
}
168171
else {
169172
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyLong_Type));
@@ -182,10 +185,11 @@ dummy_func(void) {
182185
if (temp == NULL) {
183186
goto error;
184187
}
185-
OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp));
188+
res = sym_new_const(ctx, temp);
189+
Py_DECREF(temp);
190+
OUT_OF_SPACE_IF_NULL(res);
186191
// TODO gh-115506:
187192
// replace opcode with constant propagated one and update tests!
188-
Py_DECREF(temp);
189193
}
190194
else {
191195
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyFloat_Type));
@@ -204,10 +208,11 @@ dummy_func(void) {
204208
if (temp == NULL) {
205209
goto error;
206210
}
207-
OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp));
211+
res = sym_new_const(ctx, temp);
212+
Py_DECREF(temp);
213+
OUT_OF_SPACE_IF_NULL(res);
208214
// TODO gh-115506:
209215
// replace opcode with constant propagated one and update tests!
210-
Py_DECREF(temp);
211216
}
212217
else {
213218
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyFloat_Type));
@@ -226,10 +231,11 @@ dummy_func(void) {
226231
if (temp == NULL) {
227232
goto error;
228233
}
229-
OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, temp));
234+
res = sym_new_const(ctx, temp);
235+
Py_DECREF(temp);
236+
OUT_OF_SPACE_IF_NULL(res);
230237
// TODO gh-115506:
231238
// replace opcode with constant propagated one and update tests!
232-
Py_DECREF(temp);
233239
}
234240
else {
235241
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyFloat_Type));

Python/optimizer_cases.c.h

+18-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)