mirror of https://github.com/python/cpython
gh-121165: protect macro expansion of `ADJUST_INDICES` with do-while(0) (#121166)
This commit is contained in:
parent
15232a0819
commit
6343486eb6
|
@ -432,19 +432,24 @@ parse_args_finds_byte(const char *function_name, PyObject **subobj, char *byte)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* helper macro to fixup start/end slice values */
|
/* helper macro to fixup start/end slice values */
|
||||||
#define ADJUST_INDICES(start, end, len) \
|
#define ADJUST_INDICES(start, end, len) \
|
||||||
if (end > len) \
|
do { \
|
||||||
end = len; \
|
if (end > len) { \
|
||||||
else if (end < 0) { \
|
end = len; \
|
||||||
end += len; \
|
} \
|
||||||
if (end < 0) \
|
else if (end < 0) { \
|
||||||
end = 0; \
|
end += len; \
|
||||||
} \
|
if (end < 0) { \
|
||||||
if (start < 0) { \
|
end = 0; \
|
||||||
start += len; \
|
} \
|
||||||
if (start < 0) \
|
} \
|
||||||
start = 0; \
|
if (start < 0) { \
|
||||||
}
|
start += len; \
|
||||||
|
if (start < 0) { \
|
||||||
|
start = 0; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
Py_LOCAL_INLINE(Py_ssize_t)
|
Py_LOCAL_INLINE(Py_ssize_t)
|
||||||
find_internal(const char *str, Py_ssize_t len,
|
find_internal(const char *str, Py_ssize_t len,
|
||||||
|
|
|
@ -9315,19 +9315,24 @@ _PyUnicode_TransformDecimalAndSpaceToASCII(PyObject *unicode)
|
||||||
/* --- Helpers ------------------------------------------------------------ */
|
/* --- Helpers ------------------------------------------------------------ */
|
||||||
|
|
||||||
/* helper macro to fixup start/end slice values */
|
/* helper macro to fixup start/end slice values */
|
||||||
#define ADJUST_INDICES(start, end, len) \
|
#define ADJUST_INDICES(start, end, len) \
|
||||||
if (end > len) \
|
do { \
|
||||||
end = len; \
|
if (end > len) { \
|
||||||
else if (end < 0) { \
|
end = len; \
|
||||||
end += len; \
|
} \
|
||||||
if (end < 0) \
|
else if (end < 0) { \
|
||||||
end = 0; \
|
end += len; \
|
||||||
} \
|
if (end < 0) { \
|
||||||
if (start < 0) { \
|
end = 0; \
|
||||||
start += len; \
|
} \
|
||||||
if (start < 0) \
|
} \
|
||||||
start = 0; \
|
if (start < 0) { \
|
||||||
}
|
start += len; \
|
||||||
|
if (start < 0) { \
|
||||||
|
start = 0; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
static Py_ssize_t
|
static Py_ssize_t
|
||||||
any_find_slice(PyObject* s1, PyObject* s2,
|
any_find_slice(PyObject* s1, PyObject* s2,
|
||||||
|
|
Loading…
Reference in New Issue