diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2023-03-25 12:33:14 +0900 |
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2023-03-25 12:33:14 +0900 |
| commit | 9e92984f327221cda8578718040295485e33d5ba (patch) | |
| tree | a69612b43c2e03dcd360d1b0a076af1e843cbf85 | |
| parent | 06f54ff416e63149f5b2bd770204472f1ea31ee5 (diff) | |
lib/clippy: don't SEGV on invalid tokens in DEFPY
The token value can be NULL if we run into something that failed to
parse. Throw a Python exception rather than SEGV.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| -rw-r--r-- | lib/defun_lex.l | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/defun_lex.l b/lib/defun_lex.l index 505ea59b0b..81ae497cf1 100644 --- a/lib/defun_lex.l +++ b/lib/defun_lex.l @@ -207,6 +207,10 @@ static PyObject *get_args(const char *filename, int lineno) if (tval[0] == ')') depth--; } + if (!tval) + return PyErr_Format(PyExc_ValueError, + "%s:%d: invalid token in DEFPY parameters", + filename, lineno); if (!pyArg) pyArg = PyList_New(0); PyList_Append(pyArg, PyUnicode_FromString(tval)); |
