mirror of
https://github.com/python/cpython.git
synced 2025-10-14 18:59:46 +00:00
gh-124044: protect macros expansions in _cursesmodules.c
using do { ... } while (0)
(#124045)
This commit is contained in:
parent
432bf31327
commit
e49d1b44d3
1 changed files with 28 additions and 19 deletions
|
@ -182,22 +182,31 @@ static char *screen_encoding = NULL;
|
||||||
|
|
||||||
/* Utility Macros */
|
/* Utility Macros */
|
||||||
#define PyCursesSetupTermCalled \
|
#define PyCursesSetupTermCalled \
|
||||||
if (initialised_setupterm != TRUE) { \
|
do { \
|
||||||
PyErr_SetString(PyCursesError, \
|
if (initialised_setupterm != TRUE) { \
|
||||||
"must call (at least) setupterm() first"); \
|
PyErr_SetString(PyCursesError, \
|
||||||
return 0; }
|
"must call (at least) setupterm() first"); \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define PyCursesInitialised \
|
#define PyCursesInitialised \
|
||||||
if (initialised != TRUE) { \
|
do { \
|
||||||
PyErr_SetString(PyCursesError, \
|
if (initialised != TRUE) { \
|
||||||
"must call initscr() first"); \
|
PyErr_SetString(PyCursesError, \
|
||||||
return 0; }
|
"must call initscr() first"); \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define PyCursesInitialisedColor \
|
#define PyCursesInitialisedColor \
|
||||||
if (initialisedcolors != TRUE) { \
|
do { \
|
||||||
PyErr_SetString(PyCursesError, \
|
if (initialisedcolors != TRUE) { \
|
||||||
"must call start_color() first"); \
|
PyErr_SetString(PyCursesError, \
|
||||||
return 0; }
|
"must call start_color() first"); \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* Utility Functions */
|
/* Utility Functions */
|
||||||
|
|
||||||
|
@ -2633,12 +2642,12 @@ PyTypeObject PyCursesWindow_Type = {
|
||||||
|
|
||||||
#define NoArgNoReturnFunctionBody(X) \
|
#define NoArgNoReturnFunctionBody(X) \
|
||||||
{ \
|
{ \
|
||||||
PyCursesInitialised \
|
PyCursesInitialised; \
|
||||||
return PyCursesCheckERR(X(), # X); }
|
return PyCursesCheckERR(X(), # X); }
|
||||||
|
|
||||||
#define NoArgOrFlagNoReturnFunctionBody(X, flag) \
|
#define NoArgOrFlagNoReturnFunctionBody(X, flag) \
|
||||||
{ \
|
{ \
|
||||||
PyCursesInitialised \
|
PyCursesInitialised; \
|
||||||
if (flag) \
|
if (flag) \
|
||||||
return PyCursesCheckERR(X(), # X); \
|
return PyCursesCheckERR(X(), # X); \
|
||||||
else \
|
else \
|
||||||
|
@ -2647,23 +2656,23 @@ PyTypeObject PyCursesWindow_Type = {
|
||||||
|
|
||||||
#define NoArgReturnIntFunctionBody(X) \
|
#define NoArgReturnIntFunctionBody(X) \
|
||||||
{ \
|
{ \
|
||||||
PyCursesInitialised \
|
PyCursesInitialised; \
|
||||||
return PyLong_FromLong((long) X()); }
|
return PyLong_FromLong((long) X()); }
|
||||||
|
|
||||||
|
|
||||||
#define NoArgReturnStringFunctionBody(X) \
|
#define NoArgReturnStringFunctionBody(X) \
|
||||||
{ \
|
{ \
|
||||||
PyCursesInitialised \
|
PyCursesInitialised; \
|
||||||
return PyBytes_FromString(X()); }
|
return PyBytes_FromString(X()); }
|
||||||
|
|
||||||
#define NoArgTrueFalseFunctionBody(X) \
|
#define NoArgTrueFalseFunctionBody(X) \
|
||||||
{ \
|
{ \
|
||||||
PyCursesInitialised \
|
PyCursesInitialised; \
|
||||||
return PyBool_FromLong(X()); }
|
return PyBool_FromLong(X()); }
|
||||||
|
|
||||||
#define NoArgNoReturnVoidFunctionBody(X) \
|
#define NoArgNoReturnVoidFunctionBody(X) \
|
||||||
{ \
|
{ \
|
||||||
PyCursesInitialised \
|
PyCursesInitialised; \
|
||||||
X(); \
|
X(); \
|
||||||
Py_RETURN_NONE; }
|
Py_RETURN_NONE; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue